[Python-Dev] Re: Sets: elt in dict, lst.include - really begs
for a PEP
Moshe Zadka
moshez@zadka.site.co.il
Thu, 1 Feb 2001 15:17:53 +0200 (IST)
On Thu, 1 Feb 2001 03:31:33 -0800 (PST), Ka-Ping Yee <ping@lfw.org> wrote:
[about for (k, v) in dict.iteritems(): ]
> I remember considering this solution when i was writing the PEP.
> The problem with it is that it isn't backward-compatible. It won't
> work on existing dictionary-like objects -- it just introduces
> another method that we then have to go back and implement on everything,
> which kind of defeats the point of the whole proposal.
Well, in that case we have differing views on the point of the whole
proposal. I won't argue -- I think all the opinions have been aired,
and it should be pronounced upon.
> The other problem with this is that it isn't feasible in practice
> unless 'for' can magically detect when the thing is a sequence and
> when it's an iterator. I don't see any obvious solution to this
dict.iteritems() could return not an iterator, but a magical object
whose iterator is the requested iterator. Ditto itervalues(), iterkeys()
--
Moshe Zadka <sig@zadka.site.co.il>
This is a signature anti-virus.
Please stop the spread of signature viruses!
Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6