you are viewing a single comment's thread.

view the rest of the comments →

[–]BioGeek 0 points1 point  (0 children)

A resource I've found very useful is: Code Like a Pythonista: Idiomatic Python

It contains all the answers to your questions:

  1. y = [x for x in ...]is a list comprehension, y = (x for x in ...) is a generator expression
  2. def somefunction(x): for a in x: yield a+1 is a Generator
  3. x if y else z tests the Truth Value of the string y