[IPython-User] iPython executes org.py in directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] iPython executes org.py in directory

Florian Lindner
Hello,

I have a file named org.py in the current working directory. Whenever I start ipython 4.2.0, it executes this file:

florian@asaru ~/scratch/calorg (git)-[master] % ipython
[ org.py output ]
Python 3.5.1 (default, Mar  3 2016, 09:29:07)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
[...]

florian@asaru ~/scratch/calorg (git)-[master] % mv org.py foobar.py

florian@asaru ~/scratch/calorg (git)-[master] % ipython
Python 3.5.1 (default, Mar  3 2016, 09:29:07)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
[...]

When I rename the file so something else it is no being executed.

org.py is an ordinary python script, without a shebang, and without a def __main__ (but some code on the leftmost indent).

Why is file being executed? Is its name somehow special? I haven't found anything about org.py being special.

Thanks,
Florian
_______________________________________________
IPython-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: iPython executes org.py in directory

Thomas Kluyver-2
On 20 May 2016 at 11:59, Florian Lindner <[hidden email]> wrote:
I have a file named org.py in the current working directory. Whenever I start ipython 4.2.0, it executes this file:

florian@asaru ~/scratch/calorg (git)-[master] % ipython
[ org.py output ]

I would guess something is doing 'import org'. I can't find that anywhere in our code, but it might be in a dependency, an extension, or a startup file.

If you put 'raise Exception' in your org.py file, you should get a traceback that indicates what is loading it.

Thomas

_______________________________________________
IPython-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: iPython executes org.py in directory

Florian Lindner
Am Freitag, 20. Mai 2016, 12:08:46 CEST schrieb Thomas Kluyver:

> On 20 May 2016 at 11:59, Florian Lindner <[hidden email]> wrote:
>
> > I have a file named org.py in the current working directory. Whenever I
> > start ipython 4.2.0, it executes this file:
> >
> > florian@asaru ~/scratch/calorg (git)-[master] % ipython
> > [ org.py output ]
> >
>
> I would guess something is doing 'import org'. I can't find that anywhere
> in our code, but it might be in a dependency, an extension, or a startup
> file.
>
> If you put 'raise Exception' in your org.py file, you should get a
> traceback that indicates what is loading it.

Great idea, that gives:

Traceback (most recent call last):
  File "/usr/bin/ipython", line 4, in <module>
    from IPython import start_ipython
  File "/usr/lib/python3.5/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/usr/lib/python3.5/site-packages/IPython/core/application.py", line 19, in <module>
    import shutil
  File "/usr/lib/python3.5/shutil.py", line 13, in <module>
    import tarfile
  File "/usr/lib/python3.5/tarfile.py", line 49, in <module>
    import copy
  File "/usr/lib/python3.5/copy.py", line 61, in <module>
    from org.python.core import PyStringMap
  File "/home/florian/scratch/calorg/org.py", line 66, in <module>
    raise Exception
Exception

So it's in python's core. I guess either org.py is not a good name or I should put it in a if __name__ == "__main__" clause.

Best Thanks,
Florian
_______________________________________________
IPython-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: iPython executes org.py in directory

Paul Moore
On 20 May 2016 at 12:41, Florian Lindner <[hidden email]> wrote:
> So it's in python's core. I guess either org.py is not a good name or I should put it in a if __name__ == "__main__" clause.

Looking at copy.py, this looks like it might be something specific for
Jython (which uses module names like "org.python.x" AIUI). It might be
worth raising an issue at bugs.python.org for this.

Paul
_______________________________________________
IPython-User mailing list
[hidden email]
https://mail.scipy.org/mailman/listinfo/ipython-user