473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Documentation for iteration in mappings

Hi!

I must be blind because I didn't find anything in the documentation
which says iterating over an dictionary iterates over its keys.

For example

a_dictionary = {0: "zero", 1: "one"}
for x in a:
print x

gives you

0
1

Where is this information hidden? :)

Bye,
Dennis
Oct 25 '05 #1
2 1407
Dennis Benzinger wrote:

I must be blind because I didn't find anything in the documentation
which says iterating over an dictionary iterates over its keys.

For example

a_dictionary = {0: "zero", 1: "one"}
for x in a:
print x

gives you

0
1

Where is this information hidden? :)


You should examine your program. Simply pasting the code above to the
Python shell fails as expected:

$ python
Python 2.4.2 (#1, Oct 1 2005, 14:32:09)
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
a_dictionary = {0: "zero", 1: "one"}
for x in a: .... print x
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'a' is not defined


Ciao, Michael.
Oct 25 '05 #2
On Tue, 25 Oct 2005 18:02:47 +0200, Michael Ströder wrote:
Dennis Benzinger wrote:

I must be blind because I didn't find anything in the documentation
which says iterating over an dictionary iterates over its keys. [snip] Where is this information hidden? :)


You should examine your program. Simply pasting the code above to the
Python shell fails as expected:


Yes, this is true, but also irrelevant. The question isn't about the code,
but about the documentation.

The answer does appear to be hidden quite deeply. I had to dig out an old
"What's New" for version 2.2 to find it, hidden away in a section on
iterators:

http://aspn.activestate.com/ASPN/doc...00000000000000
--
Steven.

Oct 25 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Raymond Hettinger | last post by:
Here is a discussion draft of a potential PEP. The ideas grew out of the discussion on pep-284. Comments are invited. Dart throwing is optional. Raymond Hettinger ...
59
by: Raymond Hettinger | last post by:
Please comment on the new PEP for reverse iteration methods. Basically, the idea looks like this: for i in xrange(10).iter_backwards(): # 9,8,7,6,5,4,3,2,1,0 <do something with i> The...
14
by: Raymond Hettinger | last post by:
Based on the feedback here on comp.lang.python, the pep has been updated: www.python.org/peps/pep-0322.html The key changes are: * reversed() is being preferred to ireverse() as the best...
2
by: Abdullah Khaidar | last post by:
Is there any iteration style we must use to get faster processing time? I've tried with some style to concat number in list. But I still don't know which one is the recommended style. >>> def...
0
by: Bruce B | last post by:
Hi group, I'm experiencing some extreme weirdness over the last week with IIS related to it's Mappings and how .NET is behaving. I can't explain the behavior as it seems very random. Our...
3
by: Adam | last post by:
Its my understanding that in asp.net 2.0 you can write an httpmodule that will acts as a wildcard handler and pass requests on to the proper engine, for instance, asp or perl for example, In the...
1
by: john | last post by:
Hi I'm suddenly having a problem running ASP.Net apps from an XP Pro laptop machine which was working fine. The apps now just time out will not render anything in the Browser. I have...
3
by: john | last post by:
Hi I'm still having a problem with missing ISAPI mappings and my browser will not render ASP.Net pages. Its fine with ASP though. I have even reloaded IIS and the Framework v1.1.4322...
7
by: SlimFlem | last post by:
I have searched hard for 2 days on this and keep hitting a wall. I have a custom IHttpHandler setup to do Url mappings to prop up some old Urls for our site. I have also created a wildcard...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.