the annoying, verbose self

MonkeeSage MonkeeSage at gmail.com
Tue Nov 27 06:12:24 EST 2007


On Nov 27, 4:22 am, Bruno Desthuilliers

> You don't have to subclass function to define a callable type that
> implements the descriptor protocol so it behaves just like a function in
> the context of an attribute lookup.

I'm aware, and I understand that python's types (as with other duck-
typed languages) are basically just an object's capabilities; I was
just pointing out that, if needed (though I can't think of why
offhand...mabye some kind of sandbox?), you can detect built-in
functions. Hmm...but then again, it seems that shadowing a built-in
function still reports as it's type as FunctionType...

In [1]: from types import FunctionType

In [2]: def len(x):
   ...:     # mischief
   ...:     pass
   ...:

In [3]: type(len) == FunctionType
Out[3]: True

Regards,
Jordan



More information about the Python-list mailing list