On 25/07/2013 4:31 AM, Ethan Furman wrote:
   2) Hopefully learn something about when a view is useful.

I haven't seeen this mentioned - forgive me if it's a repeat - but views are constant references to whichever set they represent.

Python 2.7:

>>> dd = dict(a=1,b=2,c=3)
>>> keys = dd.keys()
>>> 'a' in keys
True
>>> dd['d'] = 4
>>> 'd' in keys
False

Python 3.3:
>>> dd = dict(a=1,b=2,c=3)
>>> keys = dd.keys()
>>> 'a' in keys
True
>>> dd['d'] = 4
>>> 'd' in keys
True

If part of my code is only interested in what keys or values are present, it doesn't need to be given a reference to the full dictionary, just to whichever view it cares about.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to