[IPython-dev] Where should __future__ statements affect the interactive environment.
Mon Apr 23 13:46:34 CDT 2012
I thought of another one: import * respects __all__.
Maybe it would be useful to have an %import magic, which would just
temporarily add the file path to the front of the python path and
import the file. I don't know if it would be useful, though, and the
differences between it and %run would be subtle and probably not
really understood by non-expert Python users.
On Mon, Apr 23, 2012 at 12:41 PM, Aaron Meurer <firstname.lastname@example.org> wrote:
> I thought %run was more like executing the script from the command
> line. In other words, if you have
> if __name__ == '__main__':
> then blah will be run for %run (but it wouldn't in an import).
> There are probably other invariants that hold in one situation but not
> the other.
> Aaron Meurer
> On Mon, Apr 23, 2012 at 4:44 AM, Fernando Perez <email@example.com> wrote:
>> On Mon, Apr 23, 2012 at 3:25 AM, Thomas Kluyver <firstname.lastname@example.org> wrote:
>>> On the other hand, %run (without -i) works a bit like doing `from foo
>>> import *`, in which case you don't get semantic changes from
>>> __future__ statements in foo. I'm inclined to agree with you that I'd
>>> expect __future__ statements in %run to affect the interactive
>>> environment, but I don't think it's entirely clear cut.
>> I was thinking more about what the more natural workflow would be,
>> since we pitch %run more closely related to "run a script as if you
>> had typed all that interactively" than "a shorthand for 'import *'".
>> But you are right, one could think of it either way...
>> IPython-dev mailing list
More information about the IPython-dev