Why no number methods?

Michael Hudson mwh at python.net
Tue May 15 02:13:55 EDT 2001


"Magnus Lie Hetland" <mlh at idi.ntnu.no> writes:

> It's online at O'Reilly's website. (No URL handy...)
> 
> He says that Python 3000 is a *long* way off. Whether that means that
> the type/class gap will stay open far into the future is another
> matter :)

Ah, right.  Yes Py3K probably is a long way off - but some of the
things that you might expect to be in Py3K might be in 2.2.  Or not.

> > Well, assume that we have magically healed the type/class split so
> > that all objects behave like instances.  Then imagine:
> >
> > class C:
> >     def __repr__(self):
> >         return "bongle"
> >
> > What's C.__repr__?  Quick!
> 
> <scratches head> An unbound method? (I *must* be missing something here ;)

But if all objects behave like instances, somewhere there is a class
"class" (probably written in C) that looks a bit like this:

class class:
    ...
    def __repr__(self):
        return "<class %s.%s at %d>"%(self.__module__,
                                      self.__class__,
                                      id(self))
    ...

So C.__repr__ might be expected to return a bound version of *this*
method (and in some situations will have to, as otherwise 

print C

would blow up with an exception).

Cheers,
M.

-- 
  Hmmm... its Sunday afternoon: I could do my work, or I could do a
  Fourier analysis of my computer's fan noise.
       -- Amit Muthu, ucam.chat (from Owen Dunn's summary of the year)



More information about the Python-list mailing list