[Python-Dev] pprint(iterator) (original) (raw)

Eric Smith eric at trueblade.com
Fri Jan 30 13:33:19 CET 2009


Steven D'Aprano wrote:

Eric Smith wrote:

Terry Reedy wrote:

Ron Adam wrote:

Steven D'Aprano wrote: Michael Foord wrote: Don't we have a pretty-print API - and isn't it spelled str ? Not really. If it were as simple as calling str(obj), there would be no need for the pprint module. I agree. And when I want to use pprint, there are usually additional output formatting requirements I need that isn't a "one size fits all" type of problem. I don't see how you can have a standard interface (like pprint), and have additional, per-object formatting parameters. I don't see how you can't. Other standard methods take variable arguments: init, new, call come to mind.

Those are different, since they're called on known specific objects. Having params to a generic pprint method would be more like having params to str or repr. If you know enough about the object to know which parameters to pass to its pretty-print function, then just call a normal method on the object to do the pprint'ing. But, for example, assuming pprint for a list is recursive (as it is for repr), how would you pass the arguments around?

> But that's beside the

point, I don't like pprint in any event. Too special. I'm not sure what you mean by "too special". It's no more special than any other special method. Do you mean the use-case is not common enough? I would find this useful. Whether enough people would find it useful enough to add yet another special method is an open question.

Bad choice of words on my part. I meant "too special case" for such machinery. That is, the use case isn't common enough.



More information about the Python-Dev mailing list