I found some 'wierdness' with classmethods today (in 2.5). I have a
classmethod with kwargs, and I noticed that the kwarg was, somehow, taking
on a global scope.
example:
---------
@classmethod
def classMethodName (cls, argName, kwargName={}):
doStuff
--------
1st Call--> classMethodName(argName) # kwarg is not passed in
kwarg is empty
kwarg (dictionary) ends up getting filled with data
kwarg is NOT cleared (clearing it is a workaround, though)
2nd Call--> classMethodName(argName) #same as the first
kwarg is NOT EMPTY--it contains the data from the 1st call
So somehow, the kwarg is getting global scope? Is this how classmethods
are designed to work? At first I thought I screwed up and this variable
was defined globally, but that is not the case. Also, this issue can be
worked around by either clearing the dictionary or using kwargs. I was
just looking for a better understanding as to why it was happening this
way?
Any takers?
thanks!
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe