Import error - calling with same name as script
Rick van der Zwet
rick at wzoeterwoude.net
Tue Nov 20 07:04:00 EST 2007
Hi,
Line 23 of planet.py: import planet is a bit confusing and leads to
problems when trying to install the planet using setup.py
Take a look at the attached foo.py out which is ran in both foo.py and
foo style, the first one will print Bar twice, the second version result
`in a error [1].
I would like to suggest to change the name of the library planetlib
Best regards,
/Rick
[1]
rick at dhcp-2zwet-pc94:~ 510$ ./foo.py
Bar
Bar
Exit
rick at dhcp-2zwet-pc94:~ 511$ rm foo.pyc
rick at dhcp-2zwet-pc94:~ 512$ ./foo.py
Bar
Bar
Exit
rick at dhcp-2zwet-pc94:~ 513$ rm foo.pyc
rick at dhcp-2zwet-pc94:~ 514$ mv foo.py foo
rick at dhcp-2zwet-pc94:~ 515$ ./foo
Traceback (most recent call last):
File "./foo", line 3, in ?
import foo
ImportError: No module named foo
rick at dhcp-2zwet-pc94:~ 516$
-- =
http://rickvanderzwet.nl
-------------- next part --------------
#!/usr/bin/env python
import foo
print "Bar"
def main ():
print "Exit"
if __name__ =3D=3D '__main__':
main()
More information about the devel
mailing list