[Python-Dev] Arbitrary attributes on funcs and methods
Fredrik Lundh
fredrik@pythonware.com
Wed, 12 Apr 2000 14:50:21 +0200
Paul Prescod wrote:
> * I need to associate a Java-style type declaration with a method so
> that it can be recognized based on its type during Java method =
dispatch.
class foo:
typemap =3D {}
def myfunc(self):
pass
typemap[myfunc] =3D typeinfo
> * I need to associate a "grammar rule" with a Python method so that =
the
> method is invoked when the parser recognizes a syntactic construct in
> the input data.
class foo:
rules =3D []
def myfunc(self):
pass
rules.append(pattern, myfunc)
> * I need to associate an IDL declaration with a method so that a COM
> interface definition can be generated from the source file.
class foo:
idl =3D {}
def myfunc(self):
pass
idl[myfunc] =3D "declaration"
> * I need to associate an XPath "pattern string" with a Python method =
so
> that the method can be invoked when a tree walker discovers a =
particular
> pattern in an XML DOM.
class foo:
xpath =3D []=20
def myfunc(self):
pass
xpath.append("pattern", myfunc)
</F>