[Tutor] odbchelper

Ewald Ertl ewald.ertl at hartter.com
Fri Mar 3 16:43:57 CET 2006


Hi Kent!


You are absolutely right. Sorry for my bad description.

Kent Johnson wrote:
> Ewald Ertl wrote:
>> Hi!
>>
>> How have you started the script? As far as I could see, in the Chapter 1 of
>> "Dive into Python", the odbchelper.py is just a script-File and not a module
>> to be imported, therefore the Exception with the "ImportError".
> 
> It is both, if by "just a script-File" you mean a top-level program 
> intended to be run from the command line.
> 
Yes I meant a top-level-program.

> If you import odbchelper it will give you access to the 
> buildConnectionString() function. If you run it from the command line, 
> it will also run the code after
> if __name__ == "__main__":
> 
> This is pretty common - to write a module so it can be imported or used 
> as a main program. The parts you want to run only from the command line 
> are set off by this conditional.
> 

I looked at the code of odbchelper.py in Example 2.1 in my printed Version of
"Dive into Python" and there was no "import", so I assumed some problem with the IDE.
But the Traceback came from Example 2.5 in my version.

Thanks for your response on my attempt to help
Ewald



More information about the Tutor mailing list