Python Forum
wishing for a 3-way loop construct
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wishing for a 3-way loop construct
#2
It seems to me that's what dunders are for,
in this case __iter__
Output:
__iter__(self) x.__iter__() <==> iter(x) Also called when iteration over the instance is requested, such as in a for loop. Should return an iterator suitable for iterating over all the items contained in the instance. Mapping objects, again, should consider only keys. If not present, Python attempts to call __getitem__ with integer keys starting at zero and ending when IndexError is raised. If __getitem__ is also not defined, a TypeError ('iteration over non-sequence') is raised.
For reference, if you don't have this one stored away, It's a good dunder reference: http://www.siafoo.net/article/57


You can equate this to a C++ template.
Reply


Messages In This Thread
wishing for a 3-way loop construct - by Skaperen - Feb-13-2017, 03:07 AM
RE: wishing for a 3-way loop construct - by Larz60+ - Feb-13-2017, 03:29 AM
RE: wishing for a 3-way loop construct - by nilamo - Feb-13-2017, 04:52 AM
RE: wishing for a 3-way loop construct - by Larz60+ - Feb-13-2017, 05:53 AM
RE: wishing for a 3-way loop construct - by Ofnuts - Feb-13-2017, 08:37 AM
RE: wishing for a 3-way loop construct - by Larz60+ - Feb-13-2017, 08:52 PM
RE: wishing for a 3-way loop construct - by nilamo - Feb-15-2017, 03:58 AM
RE: wishing for a 3-way loop construct - by Ofnuts - Mar-22-2017, 01:38 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020