[IPython-dev] Where should __future__ statements affect the interactive environment.

Aaron Meurer asmeurer at gmail.com
Mon Apr 23 14:46:34 EDT 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.

Aaron Meurer

On Mon, Apr 23, 2012 at 12:41 PM, Aaron Meurer <asmeurer at gmail.com> wrote:
> I thought %run was more like executing the script from the command
> line.  In other words, if you have
>
> if __name__ == '__main__':
>   blah
>
> 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 <fperez.net at gmail.com> wrote:
>> On Mon, Apr 23, 2012 at 3:25 AM, Thomas Kluyver <takowl at gmail.com> 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...
>>
>> f
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev



More information about the IPython-dev mailing list