[Python-3000] question Re: Need help completing ABC pep

Guido van Rossum guido at python.org
Mon Apr 23 05:36:04 CEST 2007


On 4/22/07, Samuele Pedroni <pedronis at openendsystems.com> wrote:
> If we keep s % d (do we? reading the list archives and the peps didn't
> give an answer, I suppose it depends if PEP 3101 is accepted):
>
> will it check if d is a Mapping or continue to use the current heuristics?
>
> I suppose this is a legitimate question for other corners of the
> language, std lib.

Any place that currently uses a heuristic should be changed to check
for Mapping instead (actually, in this particular case BasicMapping,
as the % operator doesn't need to iterate over the keys or items). And
most places that currently check for a dict should probably check for
a Mapping or BasicMapping as well. BUT BUT BUT -- this is only for
places that already check (like s%d). Places that just plunge in and
call __getitem__ should continue to do so and should not be modified
to require a flavor Mapping. Similarly, assignment to sys.stdout
shouldn't be constrained to subclasses of io.IOBase; we can and should
continue to use duck typing where it makes sense.

PS. I fully intend to be dropping s%d in favor of the PEP 3101 solution.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list