Question about generators

Alan Bawden alan at csail.mit.edu
Sat Mar 6 01:36:44 EST 2021


   >>>
   >>> s = []
   >>> s.append(((b, c) for b, c in a))
   >>> s
   [<generator object <genexpr> at 0x0000019FC3F863C0>]
   >>>

   TIA for any insights.

Replace "append" above with "extend" and observe the results.  Then
ponder the difference between append and extend.  I suspect that the
heart of your confusion actually has nothing to do with generators.

-- 
Alan Bawden


More information about the Python-list mailing list