[Python-ideas] Changing str(someclass) to return only the class name

Guido van Rossum guido at python.org
Sun Oct 23 22:26:23 CEST 2011


On Sun, Oct 23, 2011 at 11:37 AM, Bruce Leban <bruce at leapyear.org> wrote:
> One advantage of the way it works now is that if you have a class, function
> or module when you're not expecting it, print tells you what's going on.
> Compare these:
>
>>>> print('9'.isdigit)
> isdigit
>
> vs
>
>>>> print('9'.isdigit)
> <built-in method isdigit of str object at 0x01D5A038>

Fortunately, that particular example won't change, because '9'.isdigit
is not a function -- it is a bound method. They're different object
types.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list