Nested Mapping
Raymond Hettinger
raymond.activestate at gmail.com
Fri Oct 22 16:57:50 EDT 2010
On Oct 22, 4:17 am, Peter Otten <__pete... at web.de> wrote:
> I just read the recipe, and it looks good to me except for the len() and
> iter() implementations:
>
> >>> a = Context()
> >>> a["x"] = 1
> >>> b = a.new_child()
> >>> b["x"] = 2
> >>> len(b)
> 2
> >>> b.keys()
>
> ['x', 'x']
>
> I would have expected equal keys to occur/count just once.
Thanks for reviewing the recipe.
Since only the first (unshadowed) 'x' is accessible, I can
see why it would make sense to count it only once.
Raymond
More information about the Python-list
mailing list