Transcrypt
Transcrypt copied to clipboard
Problem with a particular tuple comprehension
self.pages = tuple (Page (self, pageIndex) for pageIndex, Page in enumerate (self.Pages)])
doesn't seem to work. Workaround: Use a list comprehension in this case.
For the record, "tuple comprehension" isn't technically a Python thing in itself, you're technically composing the following two things:
- a generator expression, with
- the
tupleconstructor being able to take any iterable.
Re "bug?" tag: I would say that it's a bug, because as a Python developer I would expect it to work, because it is very Pythonic norm and best practice for things to accept any iterable, unless it needs to take something more specific.