Parametrized definitor

Alexander V. Voinov avv at quasar.ipa.nw.ru
Wed Jan 24 15:21:57 EST 2001


Hi All,

How you'd like this:

def(a=1, b='Hello') f(x):
	pass

print f.a

Same for lambda :-)

Alexander

Terry Reedy wrote:
> 
> "Mike Romberg" <romberg at smaug.fsl.noaa.gov> wrote in message
> news:ul3snm8dfae.fsf at smaug.fsl.noaa.gov...
> >
> >   I've been messing around with python-2.1a1 and have discovered the
> > new feature 'function attributes'.  The project I'm currently working
> > on can really use this feature.
> > http://python.sourceforge.net/peps/pep-0232.html
> 
> Not having read the PEP, I wondered 'what is this good for?' when I read
> GvR's announcement.
> The PEP gives three possible uses.  Is your use something different?  (that
> you can tell us?)
> 
> Now having read the PEP, it occurs to me that this could be used to supply
> optional type information to a compiler without any of the ugly syntax
> changes that have been proposed and so far rejected.
> 
> # example of function with identified parameter and return type information
> from type import *
> def f(a,b): pass
> f.argtypes = {'a':IntType, 'b':ListType, 'f':StringType}
> 
> Someone wanting to experiment along this line need only fix on an attribute
> name and syntax and proceed without any further approvals.
> 
> Terry J. Reedy



More information about the Python-list mailing list