Re: member variables in python
- From: bruno at modulix <onurb@xxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 18:34:03 +0200
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"
Seems that you're looking for a logging package (hint: there's one in
the standard lib).
is there a better way to access this if we go with what you mentioned
in another class ..
I wanted to avoid globals thats the reason i am looking for better
solution ..
A general solution would be a combination of
1/ a Singleton or Monostate (for storing application-wide settings) and
2/ a method decorator managing additionnal responsabilities according to
the values of 1.
There are examples of Singleton/Borg/Monostate/whatnot in the Python
cookbook and elsewhere - as usual, google is your friend - and a Q&D
example of decorator doing this kind of jobs in the decorator library
http://wiki.python.org/moin/PythonDecoratorLibrary
My 2 cents
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb@xxxxxxxxxxx'.split('@')])"
.
- 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: member variables in python
- Next by Date: best way to index numerical data ?
- Previous by thread: Re: member variables in python
- Next by thread: Re: member variables in python
- Index(es):
Relevant Pages
|