There is nothing exactly equivalent. In most cases, a good alternative
is to define a class representing callable objects (i.e. having a
__call__ method). The persistent data is then stored in ordinary
object attributes.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hin...@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
Konrad already suggested using a class, which is generally good advice.
However, sometimes you need a quick fix to a program written in a
procedural style (and there's often nothing wrong with that). In that
case, consider using a module-global variable, e.g.:
ncalls = 0
def myfunction(arg):
global ncalls
ncalls = ncalls + 1
...your code goes here...
Because Python's globals are module-global, not program-global, this
is generally a safe practice.
--Guido van Rossum (home page: http://www.python.org/~guido/)
Thanks for your suggestion. I played around with the classes and figured 'em
out. However, like you mentioned, there are a lot of times where a class would
be ineffecient to use for just one variable and the global typing could be
used.
I'm really happy with the Python language. The learning curve is a LOT faster
than C. Another BIG Python plus is this newsgroup. It amazes me how fast I
can get a response to my questions. Seldom have I been able to tell people
that the internet is constructive. This newsgroup has helped me out a lot.
Thanks again...