python-2.1 function attributes

Mike Romberg romberg at smaug.fsl.noaa.gov
Wed Jan 24 13:07:25 EST 2001


>>>>> " " == Michael Hudson <mwh21 at cam.ac.uk> writes:

     > Mike Romberg <romberg at smaug.fsl.noaa.gov> writes:
    >> 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.  The feature
    >> itself would be much more useful if one could predefine a set
    >> of attributes with the function definition.  This is one of the
    >> things mentioned in the 'future directions' sections of pep 232
    >> 
    >> http://python.sourceforge.net/peps/pep-0232.html
    >> 
    >> So... I guess I'd like to put in one 'yes' vote for this
    >> extension :).

     > I suspect if you can come up with a decent syntax, it will go
     > in.  I can't though.  Any ideas?

  The second syntax proposed in pep 232 does not strike me as
elegant.  But, it does seem to be consistant with doc strings in that
they are defined (but not referenced) first thing in the function
definition:

def spam():
    """The doc string."""
    { 'attribute1' : 'val1', 'attribute2' : val2 }
    pass

  This seems workable (althought not ideal) to me.

Mike (romberg at fsl.noaa.gov)



More information about the Python-list mailing list