A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-April/003369.html below:

[Python-Dev] Arbitrary attributes on funcs and methods

[Python-Dev] Arbitrary attributes on funcs and methods [Python-Dev] Arbitrary attributes on funcs and methodsChristian Tismer tismer@tismer.com
Wed, 12 Apr 2000 16:43:30 +0200
Fredrik Lundh wrote:
> 
> 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 = {}
>     def myfunc(self):
>         pass
>     typemap[myfunc] = typeinfo

Yes, I know that nearly everything is possible to be emulated
via classes. But what is so bad about an arbitrary function
attribute?

ciao - chris

p.s.: Paul, did you know that you can use *anything* for __doc__?
You could use a class instance instead which still serves
as a __doc__ but has your attributes and more.
Yes I know this is ugly :-))

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4