On Tue, Apr 8, 2008 at 5:34 PM, Greg Ewing <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > Seems to be mass confusion all around. My proposal is: > > > > repr(int) == <class 'int'> > > str(int) == 'int' > > > > > repr(C) == <class '__main__.C'> > > str(c) == '__main__.C' > > Can I take a step back and ask why exactly we're considering > doing this? In what use cases is the current result > of str() considered too verbose?
In error messages. I've written more code than I'd like to admit that spits out errors of the form "Method frumble() expected a joojoo or geegee argument, but got a %s instead". Using type(arg).__name__ omits the module name, which can be ambiguous in some contexts (some apps have lots of different but related classes with the same name defined in different modules). Using repr(type(arg)) makes the message ugly (and longer, which matter). Making it pretty requires something like type(arg).__module__ + "." + type(arg).__name__ with an exception if __module__ is empty or '__builtin__' is usually not worth the code. A simpler str() for classes would simplify life. And don't tell me that I shouldn't be using isinstance(). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com