[Python-Dev] A syntax for function attributes?

Martin Zarate mzaratc603@rogers.com
Fri, 1 Aug 2003 03:03:03 -0400


This is my first post to this thing, but don't be gentle.  If I should go
away, say so.  Well, an ugly reverse could be made, with only a minor
modification to classmethod (the need for a callable member - it should be
there anyways).

class foo(object):
    bar = classmethod() #this doesn't work right now - it needs a
parameter - changing that is trivial.
    def myfunc(self,x,y):
        pass
    bar.callable = myfunc #callable isn't in members right now, but changing
that is even more trivial.
    del myfunc

not perfect, but then the classmethod thing is mentioned at the top.  Having
to create and delete myfunc just to avoid having some pointless thing left
behind in the class seems a waste - but its a problem I run into often in
modules and classes.  Some sort of "temp" variables would be nice, that get
left behind on localstofast - but they'd require a new statement, similar to
'global'.

I remember the 2.2 class tutorial mention that using the actual type-object
to make the thing was thought of as a temporary hack anyways, but I don't
know if there are specific plans for the future.  Anyhow, the "as" keyword
would seem to be better then the [] idea....

>>>def myfunctionname(x=5,y=5,z) as classmethod:
or maybe just two words, C style.
>>>def classmethod myfunctionname(x=5,y=5,z):

I've got a much more fleshed-out description of this concept (expanded to
include classes) posted at
http://members.rogers.com/pxtl/stuff/Pythondefidea.txt
rather then taking up space here.  I can't contribute to the discussion of
rules, tho, as I have no clue what you're talking about.