Re: iPython executes org.py in directory

Florian Lindner <[email protected]> Fri, 20 May 2016 13:41:35 +0200
Newsgroups gmane.comp.python.ipython.user
Message-ID <209108799.GnrZosQxWk@asaru>
Am Freitag, 20. Mai 2016, 12:08:46 CEST schrieb Thomas Kluyver:
> On 20 May 2016 at 11:59, Florian Lindner <[email protected]> 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