[Python-3000] Thoughts on dictionary views
Delaney, Timothy (Tim)
tdelaney at avaya.com
Wed Feb 21 02:08:36 CET 2007
Guido van Rossum wrote:
>> Note that some changes to the underlying object may invalidate the
>> view, in which case using it will throw an exception.
> No, this only invalidates an in-progress iterator.
Yeah - that's what I meant - just couldn't think if there were any other
situations that might (at least with the standard views).
>> Note also that there is nothing preventing someone from creating a
>> view-like class that allows changing the underlying object through
>> it, but such a class should probably not be described as a view.
> You can also think of dict views as a straightforward application of
> the GoF adapter pattern.
Yep - and I think that would be a good secondary explanation, instantly
understandable by anyone with much programming experience.
I think it's important though to set the expectations of what a view
will normally be used for, so that any unqualified use of the term
"view" will have a common understanding. And I think that the
unqualified "view" should mean read-only.
More information about the Python-3000