Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

Problem with a particular tuple comprehension

Open JdeH opened this issue 4 years ago • 2 comments

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.

JdeH avatar Jul 02 '21 17:07 JdeH

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 tuple constructor being able to take any iterable.

mentalisttraceur avatar Jun 10 '22 21:06 mentalisttraceur

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.

mentalisttraceur avatar Jun 10 '22 21:06 mentalisttraceur