python-2.1 function attributes

Terry Reedy tjreedy at udel.edu
Wed Jan 24 13:54:20 EST 2001


"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