[IPython-dev] Prompt manager

Thomas Kluyver takowl at gmail.com
Sat Sep 3 08:53:53 EDT 2011

There were a couple of questions we've not yet resolved about the prompt
manager code (see discussion at https://github.com/ipython/ipython/pull/507).

First, for generating prompts over ZMQ, we intended to use the
user_expressions field of an execution request, but this can't easily access
things that aren't in the user namespace, e.g. os.getcwd(). We can work
round that using the __import__("os").getcwd() form, but it feels somewhat
less than ideal. This can however be resolved at a later stage, because the
frontends currently generate prompts by themselves - my primary aim with
this is to simplify the rather convoluted code generating prompts for the
plain terminal.

Second, we've ended up with three versions of EvalFormatter:
A - Would evaluate {n/4}, but would treat {2} as a reference to a positional
B - Would evaluate {2} as an integer literal (so it's equivalent to just
putting 2 in the string).
C - Unlike A & B, will rejoin format strings to objects, so {a[:2]} will
slice, but you lose the ability to do format strings {date:%Y-%m-%d}

We were leaning towards keeping format strings separate for prompts (you can
still slice using {a[slice(None,2)]} ), but do we want to keep C around for
any other purpose in the code?

I'd favour using A - it's flexible enough to use positional arguments if we
do want to for any reason, and I don't see a use case for putting integer
literals inside format {}s.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110903/c1e6e0c7/attachment.html>

More information about the IPython-dev mailing list