[Python-Dev] pprint(iterator)

Steven D'Aprano steve at pearwood.info
Fri Jan 30 12:04:40 CET 2009


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.


 > 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.



-- 
Steven


More information about the Python-Dev mailing list