Skip to content

unpythonic 2.5.0 — "Turtles all the way down"

Latest

Choose a tag to compare

@Technologicat Technologicat released this 16 Sep 09:01
· 18 commits to master since this release

New:

  • Update one item deep inside nested containers, like Clojure's update-in and assoc-in. The path is a sequence of steps — keys, indices, and attribute names, in any mix — so dicts, lists, envs, named tuples, frozen dataclasses and frozendicts can all be walked through in one call.
    • mogrify_in_with(func, path, container) and mogrify_in_to(value, path, container) update in-place, with mogrify's semantics: every mutable container along the path keeps its identity, and an immutable one is rebuilt and stored back into its parent.
    • fupdate_in_with(target, path, func) and fupdate_in_to(target, path, value) are the functional variants, which never mutate their input and share everything off the path with it.

Fixed:

  • A shallow copy of an env — copy.copy, or fupdate given an env — now has bindings of its own. It used to share them with the original, so rebinding a name in the copy rebound it in the original too.
  • namedlambda's docstring now says it names a lambda bound in an env-assignment or let binding in either spelling, := or <<. It listed only <<, right after a bullet where := meant Python's own named expression, so a reader could conclude the walrus form is not named.
  • The REPL documentation now says that the client reads piped stdin, running each line in the session namespace — so a shell script can drive a live app with nobody at the keyboard. The docs described only the interactive session, which is the smaller half of what the client does.
    • It also names the trap that makes an automated check necessary: the session echoes the value of an expression and a statement has none, so a pipe made only of assignments prints nothing and looks identical whether it ran or not. Have such a script print something and check for it; python3 -m unpythonic.net.server is a throwaway host to test the pipe against first.