type function does not subtype

Lenard Lindstrom nada at nowhere.xxx
Tue Mar 25 04:49:09 CET 2003

"Greg Ewing (using news.cis.dfn.de)" <me at privacy.net> wrote in message
news:b5o1c0$2af4lj$1 at ID-169208.news.dfncis.de...
> Maybe something like the __metaclass__ syntax is
> called for:
>    def myfunction(args):
>      __functionclass__ = myspecialfunc
>      ...
> (I know that looks like a local variable assignment,
> but it wouldn't be. As Guido once said about something else,
> "It's a double-underscore name -- I can give it whatever
> semantics I want!")
In a class definition '__metaclass__ = something' is an actual assignment
statement. Also the class suite is executed at definition time, unlike a
function body suite, which is not. Perhaps __functionclass__ could be
external to the definition, then:

def newscope():
    __functionclass__ = myspecialfunc
    def myfunction(args):
    return myfunction
myfunction = newscope()

The def statement checks the local, as well as the global, scope for

I tentatively suggest a syntax change to def which restricts the scope of
the function class to a particular definition while keeping the class
specifier external to the function body:

def(funcsubtype) afunc(args):

where '(funcsubtype)' is optional, of coarse. I haven't checked the Python
grammar to see if anything breaks, but I don't see any ambiguities, and the
syntax change is isolated to the def statement.

Lenard Lindstrom
"<%s@%s.%s>" % ("len-l.", "telus", "net")

More information about the Python-list mailing list