importing a user file in Python

waltbrad waltbrad at hotmail.com
Sat Dec 1 02:42:34 EST 2007


Hello. I'm brand new to Python. I'm running a Kubuntu system and
working through the "diveintopython" tutorial.  The author of that
gives these instructions:

>>> import odbchelper
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
>>> print odbchelper.buildConnectionString(params)
server=mpilgrim;uid=sa;database=master;pwd=secret
>>> print odbchelper.buildConnectionString.__doc__
Build a connection string from a dictionary
Returns string.


I've tried to enter this into the interpreter but the very first
instruction:

>>>import odbchelper

gives me this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named odbche

I've tried to enter the pathname:

>>> import /home/jw/diveintopython-5.4/py/odbchelper.py

and I get this error:

>>> import /home/jw/diveintopython-5.4/py/odbchelper.py
  File "<stdin>", line 1
    import /home/jw/diveintopython-5.4/py/odbchelper.py
           ^
SyntaxError: invalid syntax
>>>


Where on my system do I have to place these files before the
interpreter will import them?

Thanks.



More information about the Python-list mailing list