Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43342 > unrolled thread
| Started by | inshu chauhan <insideshoes@gmail.com> |
|---|---|
| First post | 2013-04-11 15:18 +0530 |
| Last post | 2013-04-11 23:33 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Can I iterate over a dictionary outside a function ? inshu chauhan <insideshoes@gmail.com> - 2013-04-11 15:18 +0530
Re: Can I iterate over a dictionary outside a function ? Alexander Blinne <news@blinne.net> - 2013-04-11 23:33 +0200
| From | inshu chauhan <insideshoes@gmail.com> |
|---|---|
| Date | 2013-04-11 15:18 +0530 |
| Subject | Can I iterate over a dictionary outside a function ? |
| Message-ID | <mailman.452.1365673689.3114.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
I have a prog in which a functions returns a dict but when I try to iterate over the dict using iterkeys, It shows an error. I think its because only address of the dictionary is returned so cannot be iterated upon. Please suggest some way by which it can be made possible to iterate over the dictionary using iterkeys outside the function ?
[toc] | [next] | [standalone]
| From | Alexander Blinne <news@blinne.net> |
|---|---|
| Date | 2013-04-11 23:33 +0200 |
| Message-ID | <51672c36$0$6623$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #43342 |
Am 11.04.2013 11:48, schrieb inshu chauhan: > I have a prog in which a functions returns a dict but when I try to > iterate over the dict using iterkeys, It shows an error. 1) Show us your code in form of a minimal "working" example, "working" means that it should show us what you expect it to do but at the same time shows the behaviour you complain about. 2) Show us your actual error message! > I think its > because only address of the dictionary is returned so cannot be iterated > upon. Python does not use addresses, it uses references. And as long as you have a valid reference to a dict assigned to some name in some namespace you should be able to iterate over its keys using some_dict.iterkeys().
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web