[Tutor] viewkeys,viewvalues,viewitems : Use Cases

Santosh Kumar rhce.san at gmail.com
Wed Feb 26 08:04:18 CET 2014


All,

I defined a dictionary a below.

In [14]: a = {'a':1,'b':2,'c':3}

In [15]: type(a)
Out[15]: dict

Funtion associated with dictionaries.

In [11]: print a.viewkeys()
dict_keys(['a', 'c', 'b'])

In [12]: print a.viewvalues()
dict_values([1, 3, 2])

In [13]: print a.viewitems()
dict_items([('a', 1), ('c', 3), ('b', 2)])


Where do i use these , can i get any user cases.

Thanks,
santosh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140226/a4296d9d/attachment.html>


More information about the Tutor mailing list