Re: member variables in python
- From: Kent Johnson <kent@xxxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 12:21:00 -0500
PyPK wrote:
ok I reason I was going with globals is that i use this variable in
another class something like this along with above
testflag = 0
class AA:
def __init__(...):
def methos(self,...):
global testflag
testflag = xx
class BB:
def __init__(...):
def method2(..):
if testflag:
print "do this"
is there a better way to access this if we go with what you mentioned
in another class ..
1. Tell BB about the AA instance when it is created:
class BB:
def __init__(self, aa):
self.aa = aa
def method(self):
if self.aa.testflag:
2. Pass the flag to BB.method() directly:
def method(self, testflag):
if testflag:
Kent
.
- References:
- member variables in python
- From: PyPK
- Re: member variables in python
- From: Kent Johnson
- Re: member variables in python
- From: PyPK
- member variables in python
- Prev by Date: Re: re.sub problem
- Next by Date: Re: logging producing redundant entries
- Previous by thread: Re: member variables in python
- Next by thread: Re: member variables in python
- Index(es):
Relevant Pages
|
|