Extreme n00b question

A

Anupam Kapoor

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
 
E

Erik Max Francis

Anupam said:
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')
 
A

Anupam Kapoor

,----
| Something like
| a_simple_python_example = __import__('a-simple-python-example')
`----

thanks ! that works.

kind regards
anupam
 
M

Michael Hoffman

Anupam said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top