469,926 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Extreme n00b question

hi all,

a python n00b, so please bear with me. i have a simple question:

i generally name python sources as a-simple-python-example.py. when i
try to import a module named as above, i (obviously) get tracebacks
from python interpreter.

is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_python_example.py', which then works.

thank you
kind regards
anupam

Jul 26 '05 #1
3 1348
Anupam Kapoor wrote:
is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_python_example.py', which then works.


Something like

a_simple_python_example = __import__('a-simple-python-example')

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
If the sky should fall, hold up your hands.
-- (a Spanish proverb)
Jul 26 '05 #2
,----
| Something like
| a_simple_python_example = __import__('a-simple-python-example')
`----

thanks ! that works.

kind regards
anupam

Jul 27 '05 #3
Anupam Kapoor wrote:
i generally name python sources as a-simple-python-example.py. when i
try to import a module named as above, i (obviously) get tracebacks
from python interpreter.

is there a way to continue naming python sources as above, and still
use it as python modules ? i can ofcourse change the name to
'a_simple_python_example.py', which then works.


Your question has already been answered, but I think your life (and that
of anyone trying to use your code) would probably be easier if you
switched to underscores.
--
Michael Hoffman
Jul 27 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by newgenre | last post: by
6 posts views Thread by Charles | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.