python classes

William D. Gill wmgill at gcgroup.net
Thu Mar 4 11:14:23 EST 2004


I'm new to python and am probably trying too many new things at once, but
here goes.

I am working with a (MySQL) database and am trying to make a html /python
interface for editing records.
Data is broken up into several tables, and related by customer number.  For
example one table contains basic information about the customer, one table
phone numbers (one record for published number, one for cell phone, etc,
all customers will have at least one record here).

I want to use python classes in my code so I have a couple of  questions
about python classes:

1) can a class __init__ have multiple "signatures like in C++  i.e.
MyClass( int, string), . MyClass(int) ?
2) can a class attribute be an instance of another class or is multiple
inheritance the proper answer?
3) Can I make instantiation fail if an invalid customer number is use, and
wrap the "a=MyClass(cusid=999) in an exception?

Thanks in advance,

Bill






More information about the Python-list mailing list