problems with the types module

David Necas (Yeti) yeti at physics.muni.cz
Wed Dec 11 16:20:29 EST 2002


On Wed, Dec 11, 2002 at 01:05:53PM -0800, Erik Max Francis wrote:
> Michele Simionato wrote:
> 
> > i.e. the same object is seen as a function inside the class scope and
> > as an
> > instance method outside the class scope. To me, this fact was quite
> > surprising,
> > I don't like to have a changing type depending on the context. Maybe a
> > unique
> > 'function' type for both functions and methods would have been a
> > simpler
> > solution.
> 
> But they're not the same.  Remember that first "self" argument;
> functions and methods are handled differently, so a distinction needs to
> be made.

IIUC type(object) doesn't return type of the object, as we
all thought and as is written everywhere.  The underlying
object is unique and can have only one type (and it has not
a name, since it's just some thing in memory).

type(object) in fact returns type of the reference `object'
to the unnamed object, and this is of course contextually
dependent.

OTOH having something NOT contextually dependent would be
nice.

Yeti





More information about the Python-list mailing list