On Sat, Jun 15, 2013 at 2:41 PM, Jim Mooney <cybervigila...@gmail.com>wrote:
> When I try to get the keys of a dictionary, such as d.keys(), I get > the below instead of a plain list, and it's not very usable. How can I > use the keys from this like it was a list, or is this basically > useless other than to see the keys or values? > > *** Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC > v.1600 32 bit (Intel)] on win32. *** > >>> d.keys() > dict_keys(['alpha', 'olf', 'bog', 'dog']) > I'm not sure what you want to do with your keys, but very commonly people do this: for k in d: # do something with k I'm using python 2.7 but here is an example: >>> d ={'a': 1, 'b': 2} >>> d {'a': 1, 'b': 2} >>> d.keys() ['a', 'b'] >>> for k in d: ... print k ... a b >>> > -- > Jim > After indictment the bacon smuggler was put on the no-fry list > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick http://joelgoldstick.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor