problem with writing a simple module
bruno at modulix
onurb at xiludom.gro
Mon May 22 12:11:41 EDT 2006
nephish at xit.net wrote:
> ello there. i am having a problem getting a module to work right.
>
> i wrote a class that is going to be used in a few different scripts in
> the same directory.
>
> it looks like this:
>
> #!/usr/bin/python
This is not needed for a module.
(snip code)
> the file is saved as DbConnector.py
The most common convention is to name modules all_lower, and keep
CamelCaseNames for classes.
> and made executable.
This is not needed for a module.
You may want to make "scripts" (ie: modules that has to be runned as
main program" executables and then add the shebang. Other modules (the
ones that are meant to be used via import) don't need this.
> then i get this in idle
>
>
>>>import DbConnector
>>>x = DbConnector()
>
>
> then it tells me that the module object is not callable.
cf Larry's answer. You may also want to browse the very recent (may 19)
thread named "noob import question".
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list