[Python-3000] How much should non-dict mappings behave like dict?
skip at pobox.com
skip at pobox.com
Fri Sep 12 14:59:37 CEST 2008
Eric> Given items(), I don't see why you'd ever need "zip(a.keys(),
Eric> a.values())" to work.
Eric> Antoine makes many of these same points in the issue comments.
And as I pointed out there's no telling what users will do. The
zip(keys,values) behavior works for dicts and has probably worked for other
mapping types. I'm just asking here whether or not the Python documentation
should be more explicit about what is and isn't expected of mapping types.
Eric> But then I have no current or imagined use case that would rely on
Eric> this behavior. Others may of course disagree. Has anyone ever seen
Eric> code that relies on this? Might such code predate items()?
Or might accidentally work:
keys = d.keys()
...do something with keys and other lists...
# sometime later...
vals = d.values()
...do something with vals and those other lists...
It might just be by accident that the code works, or it might be code which,
as you indicated, predates items() (though it's been around quite awhile
now).
The point of only addressing this to the topic of Python 3 is that this is
presumed to be the place where we remove as many warts as possible. It
would also be nice to tighten up the documentation in these somewhat murky
areas.
Skip
More information about the Python-3000
mailing list