[Tutor] viewkeys,viewvalues,viewitems : Use Cases

Santosh Kumar rhce.san at gmail.com
Wed Feb 26 19:11:19 CET 2014


I want to understand about where to use ,
viewkeys()
viewvalues()
viewitems()

Thanks,
santosh


On Wed, Feb 26, 2014 at 6:59 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> On 26/02/14 07:04, Santosh Kumar wrote:
>
>  I defined a dictionary a below.
>>
>> In [14]: a = {'a':1,'b':2,'c':3}
>> ...
>>
>> 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.
>>
>
> What is 'these'?
> Do you mean:
>
> 1) where do I use a dictionary?
> 2) where do I use viewXXX()?
> 3) How do viewXXX differ from XXX (eg a.viewkeys v a.keys)?
>
> I'm not sure which aspect you want help with?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.flickr.com/photos/alangauldphotos
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
D. Santosh Kumar
RHCE | SCSA
+91-9703206361


Every task has a unpleasant side .. But you must focus on the end result
you are producing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140226/04c46b98/attachment.html>


More information about the Tutor mailing list