erratum:

On 01/18/2014 12:13 PM, spir wrote:
[Note, just to compare: in Lua, this little magic making builtin sequences
special does not exist. So, to iterate over all items or pairs of a Lua table,
one would write explicitely, resp.:
     for key,val in pairs(t)
     for item in ipairs(t)
where pairs & ipairs resp. create iterators for (key,val) pairs or indexed items
of a table (used as python lists or dicts). Functions pairs & ipairs are
builtin, but it's also trivial to make iterators (or generators) in Lua, since
it has 'free' objects we don't even need classes for that.]

Read instead:

      for _, item in ipairs(t)
      for idx, item in ipairs(t)

Lua's builtin 'ipairs' returns both index and item.
[Never post a piece of code you have not run ;-)]

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to