Hi all,

Is there a guideline on where instance member variables should be set within a 
class?  That is, is it a bad idea to set self variables within private member 
functions rather than returning them to the enclosing caller?  Or should I 
avoid calls to internal functions from other member functions altogether (even 
if they are somewhat complex)?

class Foo:
    def __init__(self, a):
        self._f1(a)
    def _f1(self, a):
        self.a = a

-or-

class Foo:
    def __init__(self, a):
        self.a = self._f1(a)
    def _f1(self, a):
        return a

The first method seems to me to 'hide' where the variables get set, but in 
looking through some of my site-packages, developers seem to do this both ways.

As always, thanks for help,
matt
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to