A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-January/085718.html below:

[Python-Dev] pprint(iterator)

[Python-Dev] pprint(iterator)Paul Moore p.f.moore at gmail.com
Fri Jan 30 13:02:24 CET 2009
2009/1/30 Steven D'Aprano <steve at pearwood.info>:
>> 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.

In my view, the issue is that as a special method, *either* it has to
be included on all core types (too intrusive for something as
non-critical as pprint) *or* pprint has to hard-code the behaviour for
core types and still fall back to the special method for non-core
types  (ugly and a maintenance problem keeping the type tests up to
date).

Some sort of registry of type-specific implementation functions
(whether you call it a generic function or just put together a custom
implementation for pprint alone) is more flexible, and less intrusive.
It also allows end users to customise the behaviour, even for core
types.

In all honesty, I think pkgutil.simplegeneric should be documented,
exposed, and moved to a library of its own[1]. It's precisely what is
needed for this type of situation, which does come up fairly often. I
don't think ABCs do what's needed here (although maybe I'm missing
something - if so, I'd be interested in knowing what).

I'd be willing to look at creating a patch, if the consensus was that
this was an appropriate approach and there was a reasonable chance of
it being accepted (assuming my code wasn't rubbish :-))

Paul.

[1] Note - I have no opinion on the quality of the code, I haven't
reviewed it, I am assuming it's OK on the basis that it has been
present and in use internally in the pkgutil module for some time now.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4