473,785 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Word for a non-iterator iterable?

Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not quite right.
Jul 18 '05 #1
5 2087
Leif K-Brooks wrote:
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not quite right.


How about 'reiterable'?

--
Vincent Wehren
Jul 18 '05 #2
Leif K-Brooks <eu*****@ecritt ers.biz> wrote:
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not quite right.


Not just ``technically'' -- a dict is a good and very common example of
just such a "non-iterator, non-sequence iterable".

As you're focusing on "can be iterated over multiple-times", I like
"re-iterable"; it centers on what you can DO with the object, rather
than quibbling what it ISN'T;-)
Alex
Jul 18 '05 #3

"vincent wehren" <vi*****@visual trans.de> wrote in message
news:cu******** **@news2.tilbu1 .nb.home.nl...
Leif K-Brooks wrote:
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?

The 'therefor' above is a non sequitor. A non-iterator iterable can also
be non-reiterable.
How about 'reiterable'?


I agree. Reiterability is essential for some algorithms, while I am hard
put to think of a situation in which non-iterator-ness, by itself, is.

Terry J. Reedy


Jul 18 '05 #4
Leif K-Brooks <eu*****@ecritt ers.biz> wrote in message news:<36******* ******@individu al.net>...
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not quite right.


"reiterable ". I think I was the first to use this word on
comp.lang.pytho n.

If you have code that requires this property might want to use this
function:

..def reiter(x):
.. i = iter(x)
.. if i is x:
.. raise TypeError, "Object is not re-iterable"
.. return i

example:

..for outer in x:
.. for inner in reiter(y):
.. do_something_wi th(outer, inner)

This will raise an exception when an iterator is used for y instead of
silently failing after the first time through the outer loop and
making it look like an empty container.

When iter() returns a new iterator object it is a good hint but not a
100% guarantee that the object is reiterable. For example, python 2.2
returned a new xreadlines object for iterating over a file but it
messed up the underlying file object's state so it still wasn't
reiterable. But when iter() returns the same object - well, that's a
sign that the object is definitely not reiterable.

Oren
Jul 18 '05 #5

"Oren Tirosh" <or**@REMOVETHI S1.hishome.net> wrote in message
news:cf******** *************** ***@posting.goo gle.com...
But when iter() returns the same object - well, that's a
sign that the object is definitely not reiterable.


Unless, of course, __iter__ resets the iteration variable to its starting
value. But it would definitely not be simultaneously doubly iterable, as
one would want to compute a self crossproduct. And one could object that
such an __iter__ is not proper for an iterator (return self and do nothing
else). So such an __iter__ should better be written, perhap as a generator
function, to return an independent object with independently initialized
iteration variable.

Terry J. Reedy

Jul 18 '05 #6

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

Similar topics

17
6296
by: Mike | last post by:
I am trying to write a web page where a person can click on a word document and MS Word is launched instead of the document being displayed in the IE browser. I have been able to launch MS Word but only when I create a shortcut for the document. However a pop-up comes up with save and/or open instructions. I do not want the pop-up to come up. Mike
14
19185
by: Singleton | last post by:
Can some one guide me what is word boundary? google is no good for me for this thanks in advance
1
6906
by: Markus Ernst | last post by:
Hi I wrote a function that "normalizes" strings for use in URLs in a UTF-8 encoded content administration application. After having removed the accents from latin characters I try to remove all non-word characters from the string: // PCRE syntax: $string = preg_replace("/(+)/", "-", $string);
0
2323
by: jwa6 | last post by:
We have recently went to access 2003 from access 97. And from word 97 to Word 2003. We have an Access application we use for ms word mail mergers to a 5160 mail label format. The data for the Access mdb is linked to an Oracle db thru ODBC. There are 2 access union qrys that we use to get the correct field for the labels. Going thru the 'mail merge' wizard in MS word - we no longer see those union qrys. (no union qry shows on the word...
6
2683
by: Ryan Muller | last post by:
My company just upgraded from Access 97 to Access 2003 today and we are having some issues in a database that generates a Word document from information selected in a form. Here is the code we were using without issue previous to the switch: 'Start Word and create a new doc from the template Set objWord = CreateObject("Word.Basic") objWord.AppMaximize "Microsoft Word", 1 objWord.FileNew Template:=StrTemplPath & "letter.dot"
0
6104
by: David Akerman | last post by:
Hi, Background ======== I've written a Web App in C# which controls a pool of Word Applications for mailmerge purposes (not ideal using Word non-interactively I know, but I have explored alternatives, and they all introduced various other problems, leading me to discount them). The main issue with this solution is that when there are problems with the
0
1334
by: leeonions | last post by:
Hi there, i am trying to use regular expressions to search through a text string and replace a given whole word. take the string = "The matsat on the mat!" (bad example i know) i want to replace the whole word 'mat' with the word 'cat' to give "The matsat on the cat!" (matsat was not replaced as only whole word match, cat on the other
2
11122
by: leeonions | last post by:
Hi there, i am trying to use regular expressions to search through a text string and replace a given whole word. take the string = "The matsat on the mat!" (bad example i know) i want to replace the whole word 'mat' with the word 'cat' to give "The matsat on the cat!" (matsat was not replaced as only whole word match, cat on the other
6
9668
by: Gary Bond | last post by:
Hi All, Being a bit of a newbie with regex, I am confused when using word boundaries. For instance, I want to replace all the stand alone '.5k' that occur in an input string, with 500. In other words "this is a .5k example" goes to "this is a 500 example" The replace should not touch '.5k' that occurs inside a word. For example:
18
3873
by: Neehar | last post by:
Hello For one of the interviews I took recently, I was given an offline programming quiz. In 30 minutes I had to write code in C++ to counts the number of times each unique word appears in a given file. I tried my level best even after the quiz to come up with a solution but cudnt find an efficient one. :( This is what I did.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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
7494
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
6737
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();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3
2877
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.