"Greg Ewing" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Terry Reedy wrote: | | > As in | > | >>>>print(type(3)) | > | > int # instead of <class 'int'> | | I have the same feeling there -- the only time I'm | likely to be deliberately printing a class is for | debugging, and then I want unambiguity.
Unfortunately, *any* text printed for any object *could* have been the value of a string object. With str(), ambiguity is rife: >>> a = '1' >>> b = 1 >>> print(a,b) 1 1 So if you want unabmiguity for debugging, repr() is better since strings and only strings are surrounded by quotes. >>> print(repr(a),repr(b)) '1' 1 Guido only suggested the possibility of a more-friendly abbreviation for str, not for repr. When one calls type(x), one *knows* the answer is a class, so the boilerplate template is often redundant and unnecessary. Consider the current >>> print('Expected', type(a), '; got', type(b)) Expected <type 'str'> ; got <type 'int'> -or future- Expected <class 'str'> ; got <class 'int'> I would like to have the option of getting more normal looking text like Expected str ; got int without having to parse away the added boilerplate. If I wanted 'class' in the output, I might prefer to put it in the strings to get Expected class str ; got class int without the brackets. Should print() have an option to convert with repr instead of str? Terry Jan Reedy _______________________________________________ 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