I have a python package that I am writing and I have a problem when the standard library is imported instead of my files due to name conflicts.
For example, the file structure as shown below:
package/__init__.py
# No data in this file
package /module.py
#!/usr/bin/env python print 'Loading module.py' import signal
package /signal.py
#!/usr/bin/env python print 'Loading signal.py'
I get the following results when I run this:
$ ./module.py Loading module.py
I would like to get:
$ ./module.py Loading module.py Loading signal.py
Actual question:
So, when I run module.py , it import signal goes to the stdlib version. How can I get module.py to import signal.py instead?
As noted in the tags, this should be possible to run on python-2.4.3. Although this is an old version, this is what is included in RHEL 5.
Additional Information
Just for more information, I explicitly set the following setting:
[10:30pm][~/test] tree . . |-- package | |-- __init__.py | |-- module.py | `-- signal.py `-- script [10:30pm][~/test] cat script #!/usr/bin/env python from package import signal [10:30pm][~/test] cat package/__init__.py [10:30pm][~/test] cat package/module.py #!/usr/bin/env python print "Loading module.py" import signal [10:30pm][~/test] cat package/signal.py #!/usr/bin/env python print "Loading signal.py" [10:30pm][~/test] python ./script Loading signal.py [10:32pm][~/test] python ./package/module.py Loading module.py [10:32pm][~/test] python -m package.module python: module package.module not found
Note that when I ran ./package/module.py , the print statement in ./package/signal.py was not launched. This means that the loaded signal is one of stdlib.
source share