[Python-Dev] Classmethod Help
Raymond Hettinger
python@rcn.com
Mon, 25 Nov 2002 18:07:05 -0500
GvR pointed me to you guys for help in the C
implementation of the patch for a dictionary class method:
class dict:
def fromseq(cls, iterable, value=None):
"""Return a new dictionary with keys from iterable and values equal to value."""
result = {}
for elem in iterable:
result[elem] = value
return result
fromseq = classmethod(fromseq)
print dict.fromseq('collaborative')
print dict().fromseq('associative')
I've already C code the fromseq() as defined as above.
The question is how to make it a class method and attach
it to the dictionary type object.
If you can help, please send me a note. Thanks in advance.
BTW, I know this is ordinarily not the place to ask for
help, but there are only a handful of people who understand
descriptors at the C level (and most of them are currently
100% consumed by Zope priorities).
Raymond Hettinger