I've got a fairly large script that uses a dictionary (called 'ipDic')
each
value of which is a dictionary which in turn also has values which are
not
simple types.
Instead of producing a simple list,
"""
ips = ipDic.keys()
print(ips)
"""
yields
"""
dict_keys(['61.147.107.120', '76.191.204.54', '187.44.1.153'])
"""
Searching my code for 'dict_keys' yields nothing. I've no idea where it
comes from.
I've been unable to reproduce this behaviour using simpler dictionaries
which seem to work as I expect:
d = dict(a=1, b=2, c=3)
d
{'a': 1, 'c': 3, 'b': 2}
d.keys()
['a', 'c', 'b']
print(d.keys())
['a', 'c', 'b']
Can anyone shed light on why instead of getting the <list I'm expecting>
I
get "dict_keys( <list I'm expecting> )"?
(Using Python3, on Ubuntu 12.4)
Thanks,
Alex
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor