"parent" in a class __init__ def?

Ray Schumacher subscriber100 at rjs.org
Sat Jun 10 11:51:22 EDT 2006


What is the feeling on using "parent" in a class definition that 
class methods can refer to, vs. some other organization ?
Should all relevant objects/vars just be passed into the method as needed?
It seems like including "parent" in the class def is just like a 
class variable, which most do not recommend.

An example:
class LXSerial:
     def __init__(self, parent, debug=False):
     ...
     def connect(self, port, baud=9600, ptimeout=10):
         if self.debug:
             self.connectedPort = StringIO.StringIO(':A#')
         else:
             if self.parent.model=='LX200GPS': ptimeout = 240
             ...

Ray
  




More information about the Python-list mailing list