Serdar Tumgoren wrote:
(You top-posted. On this list, you should put your response at the end, or inline if needed. It makes it much easier to follow the thread)Thanks to you both for the suggestions. I think I'll try the approach below. But just one follow-up: should I be setting "self.tablename", or is a static attribute ("tablename") the correct approach?A nice way to do this is with a class attribute. For example: class Committee(object): def get_data(self): sql ="" select id, name from table_'%(tablename)s' """ % {'tablename':self.tablename} class CandidateCommittee(Committee): tablename =CandidateTable' PresidentialCommittee(Committee): tablename =PresidentialTable' When you call Committee.get_data() it will get tablename from the class of the instance being used.
Since you presumaby want the value tablename to be the same for all instances of a given class, you should use a class attribute, as Kent said.
DaveA _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
