[Python-Dev] printing xrange objects (original) (raw)

Fred L. Drake, Jr. fdrake@beopen.com
Thu, 3 Aug 2000 09:06:51 -0400 (EDT)


At various points, there have been comments that xrange objects should not print as lists but as xrange objects. Taking a look at the implementation, I noticed that if you call repr() (by name or by backtick syntax), you get "the right thing"; the list representation comes up when you print the object on a real file object. The tp_print slot of the xrange type produces the list syntax. There is no tp_str handler, so str(xrange(...)) is the same as repr(xrange(...)). I propose ripping out the tp_print handler completely. (And I've already tested my patch. ;) Comments?

-Fred

-- Fred L. Drake, Jr. BeOpen PythonLabs Team Member