Connecting Tech Pros Worldwide Forums | Help | Site Map

Extreme n00b question

Anupam Kapoor
Guest
 
Posts: n/a
#1: Jul 26 '05
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


Erik Max Francis
Guest
 
Posts: n/a
#2: Jul 26 '05

re: Extreme n00b question


Anupam Kapoor wrote:
[color=blue]
> 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.[/color]

Something like

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

--
Erik Max Francis && max@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)
Anupam Kapoor
Guest
 
Posts: n/a
#3: Jul 27 '05

re: Extreme n00b question


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

thanks ! that works.

kind regards
anupam

Michael Hoffman
Guest
 
Posts: n/a
#4: Jul 27 '05

re: Extreme n00b question


Anupam Kapoor wrote:
[color=blue]
> 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.[/color]

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
Closed Thread