Overzealous introspection
Bug #343992 reported by
Fernando Perez
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
IPython |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
See http://
In a nuthsell:
In [2]: x="""
...: Eh?
Object `Eh` not found.
...: """
And now, the string is actually empty...
In [3]: x
Out[3]: '\n\n'
The problem is that the introspection magic is kicking in inside of the string declaration.
This isn't 100% trivial to fix, because we do want magics in multiline input (that's been a feature for a long time). But I suppose we do need to blacklist a few ones, like the '?' behavior.
Changed in ipython: | |
status: | New → Confirmed |
To post a comment you must log in.
A user just brought a related issue to our attention. We have an example that uses Python string substitution to build up a command for an external program (gmsh). See <http:// matforge. org/fipy/ browser/ branches/ version- 2_0/examples/ diffusion/ circle. py#L70>.
When these lines are pasted into ipython, although everything seems to work, the string is garbled by %magic, and ultimately a very confusing error is thrown by our gmsh interpreter. For instance:
In [14]: s = """
....: %(radius)g;
....: """ % locals()
In [15]: s
Out[15]: '\n_ip.magic("1; ")\n'
whereas:
In [12]: s = "%(radius)g" % locals()
In [13]: s
Out[13]: '1'
Is there any way to get Python string substitution syntax to override %magic commands in multiline strings?