473,788 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iteritems() and enumerate()

Python has iteritems() and enumerate() to be used in for loops.

can anyone tell me what these are by themselves, if anything?

are they just for idiom?
thanks.

Xah
xa*@xahlee.org
http://xahlee.org/PageTwo_dir/more.html

Jul 18 '05 #1
4 23480
Xah Lee wrote:
Python has iteritems() and enumerate() to be used in for loops.

can anyone tell me what these are by themselves, if anything?

are they just for idiom?
thanks.


You would be funnier if you weren't so incompetent.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Democritus may have come from Abdera, but he was no dummy.
-- Carl Sagan
Jul 18 '05 #2
Xah Lee wrote:
Python has iteritems() and enumerate() to be used in for loops.

can anyone tell me what these are by themselves, if anything?


iteritems() is a dictionary method, which returns a lazily constructed
sequence of all (key, value) pairs in the dictionary.

enumerate(seq) is a function that returns a lazily constructed list of
(index, value) pairs for all values in a sequence.

check the relevant sections of the library reference for details.

</F>

Jul 18 '05 #3
Xah Lee wrote:
Python has iteritems() and enumerate() to be used in for loops.

can anyone tell me what these are by themselves, if anything?

are they just for idiom?


No, anyone can use them, not just idioms like you.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #4
Erik Max Francis wrote:
You would be funnier if you weren't so incompetent.


No, even if he was more competent, he'd still be a vicious, pointless
asshole:

"By the way, the pussy sex accuse us and hate us virile sex for
undiscriminatio n and hunger for humping. But look at their ugliness,
hogging with their arms and legs the moment a powerful dick or asshole
walks by. If we males are assholes, they made us so. If male animals
rape female animals, the females has a lot to do with it. Fuck them,
and fuck them for their brainlessness."

http://xahlee.org/Periodic_dosage_di...em_fatale.html

With an observational ability like that, who would *ever* listen to a
word he'd say?

Jul 18 '05 #5

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

Similar topics

5
1676
by: Pekka Niiranen | last post by:
Hi, I have Perl code looping thru lines in the file: line: while (<INFILE>) { ... $_ = do something ... if (/#START/) { # Start inner loop
5
6971
by: HL | last post by:
Hi, I need to enumerate windows and find the sum of the rect of all the windows of a specific application. In C++, I use the APIs - 'EnumWindows , GetWindowRect and UnionRect to accomplish the same. How to perform the above in c#? Is PInvoke the only way to do it or Is there some inherent c# way?
1
1814
by: smichr | last post by:
I see that there is a thread of a similar topic that was posted recently ( enumerate with a start index ) but thought I would start a new thread since what I am suggesting is a little different. I posted a very similar item to python-dev, but they said to post it here. Tutor also said that if anything is to be considered as PEP worthy, it should be run through here first. So...here goes. Whenever I use enumerate, I am doing so...
6
2031
by: Gregory Petrosyan | last post by:
Hello! I have a question for the developer of enumerate(). Consider the following code: for x,y in coords(dots): print x, y When I want to iterate over enumerated sequence I expect this to work: for i,x,y in enumerate(coords(dots)):
2
2446
by: eight02645999 | last post by:
hi, i am using python 2.1. Can i use the code below to simulate the enumerate() function in 2.3? If not, how to simulate in 2.1? thanks from __future__ import generators def enumerate(sequence): index = 0 for item in sequence: yield index, item
21
2332
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility than in the current enumerate, tightens up code in many cases, and seems that it would break no
12
2094
by: Danny Colligan | last post by:
In the following code snippet, I attempt to assign 10 to every index in the list a and fail because when I try to assign number to 10, number is a deep copy of the ith index (is this statement correct?). .... number = 10 .... So, I have to resort to using enumerate to assign to the list:
19
37273
by: Drew | last post by:
When is it appropriate to use dict.items() vs dict.iteritems. Both seem to work for something like: for key,val in mydict.items(): print key,val for key,val in mydict.iteritems(): print key,val Also, when is it appropriate to use range() vs xrange(). From my
2
8954
by: rabad | last post by:
Hi, I've created a custom filter based on HTMLParser, with the following source: class Filter(HTMLParser): def __init__(self, keyfile): HTMLParser.__init__(self) mykwfile = open(keyfile, 'r') self._keywords =
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.