python-2.1 function attributes
Mike Romberg
romberg at smaug.fsl.noaa.gov
Thu Jan 25 12:26:22 EST 2001
>>>>> " " == Michael Hudson <mwh21 at cam.ac.uk> writes:
> I suspect if you can come up with a decent syntax, it will go
> in. I can't though. Any ideas?
Well... I don't know if this qualifies as decent. But I'll put it
out there. The thought I have is that perhaps default attributes
could be handled like variable/keyword arguments. This would have the
nice feature of moving 'em out of the function body. I suppose we
could use '***' to indicate that the named argument is really an
attribute which the given value. Something like this:
def spam(a, ***attr1='val1', ***attr2='val2'):
pass
This would be the equivalent of:
def spam(a):
pass
spam.attr1 = 'val1'
spam.attr2 = 'val2'
Thoughts?
Mike (romberg at fsl.noaa.gov)
More information about the Python-list
mailing list