Re: [Tutor] Python Generator expressions

2019-07-23 Thread Steven D'Aprano
On Wed, Jul 24, 2019 at 11:26:26AM +1200, David L Neil wrote: > Clarifying the difference/similarity in appearance between a generator > expression and a tuple, it might help to think that it is the comma(s) > which make it a tuple! David makes an excellent point here. Except for the special ca

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Steven D'Aprano
On Tue, Jul 23, 2019 at 10:36:01PM +0530, Animesh Bhadra wrote: > Hi All, > > Need one help in understanding generator expression/comprehensions. > > This is my sample code. Lots of missing spaces in your code! Don't forget to hit the space bar between words :-) Also missing indentation, which

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Mats Wichmann
On 7/23/19 11:06 AM, Animesh Bhadra wrote: > Hi All, > > Need one help in understanding generator expression/comprehensions. > > This is my sample code. > > # This code creates a generator and not a tuple comprehensions. > my_square =(num *num fornum inrange(11)) > print(my_square) # at 0x7f3c8

Re: [Tutor] Python Generator expressions

2019-07-23 Thread David L Neil
Hi Animesh, Unfortunately the list server/email has removed the formatting from your sample, but no matter... On 24/07/19 5:06 AM, Animesh Bhadra wrote: # This code creates a generator and not a tuple comprehensions. my_square =(num *num fornum inrange(11)) print(my_square) # at 0x7f3c838c0c

[Tutor] Python Generator expressions

2019-07-23 Thread Animesh Bhadra
Hi All, Need one help in understanding generator expression/comprehensions. This is my sample code. # This code creates a generator and not a tuple comprehensions. my_square =(num *num fornum inrange(11)) print(my_square) # at 0x7f3c838c0ca8> # We can iterate over the square generator like thi