Simple Python class questions

cokofreedom at gmail.com cokofreedom at gmail.com
Fri Jun 20 07:59:57 EDT 2008


>
> Yes I was wondering about that, but I wasn't clear about when 'body'
> code (ie not contained within a def block) in the module might run
> under Python. So it seemed to be safer to place the import statement
> inside the 'constructor' to get the earliest warning of non-visibility
> of pyserial. But you seem to be implying that the body code will run
> when the class is instantiated - have I understood that right? It
> surely doesn't run when the module containing the class is imported
> into the main module - does it?? It would certainly make life easier
> to place the import in the body of the module.

Without insulting your intelligence I would advise looking at a few
python tutorials, not so much for the programming technique, but
rather how to think pythonic. A good one for using when coming from a
previous programming language is
Dive Into Python. http://www.diveintopython.org/

It does not deal with Serial specifically, but shows good examples of
practises in Python. Might be of benefit to you, and is very easy and
quick to read. :)



More information about the Python-list mailing list