python-2.1 function attributes

Carel Fellinger cfelling at iae.nl
Thu Jan 25 15:15:22 EST 2001


Mike Romberg <romberg at smaug.fsl.noaa.gov> wrote:
>>>>>> " " == 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

looks very promissing, better then what I came up with:)
The only nit-pit being that one might expect to be able to refer to
attr1 and attr2 in the function body, and perhaps one should.
And the second more serious objection being that one might think it's
possible to supply values at function call:(
-- 
groetjes, carel



More information about the Python-list mailing list