Re: Generator comprehension - list None

2016-10-18 Thread Sayth Renshaw
Thank you quite easy, was trying to work around it in the generator, the print needs to be outside the generator to avoid the collection of "None". Wasn't really liking comprehensions though python 3 dict comprehensions are a really nice utility. Sayth --

Re: Generator comprehension - list None

2016-10-18 Thread Chris Angelico
On Tue, Oct 18, 2016 at 11:57 PM, Jon Ribbens wrote: > I must admit I find the idea of enumerate(range(n)) quite pleasing. > gotta keep track of which numbers those numbers are! Heh! I'm assuming that's a placeholder for enumerate(some_other_iterable), where the actual

Re: Generator comprehension - list None

2016-10-18 Thread Jon Ribbens
On 2016-10-18, Steve D'Aprano wrote: > On Tue, 18 Oct 2016 10:43 pm, Sayth Renshaw wrote: >> I was solving a problem to create a generator comprehension with 'Got ' >> and a number for each in range 10. >> >> This I did however I also get a list of None. I don't

Re: Generator comprehension - list None

2016-10-18 Thread Steve D'Aprano
On Tue, 18 Oct 2016 10:43 pm, Sayth Renshaw wrote: > I was solving a problem to create a generator comprehension with 'Got ' > and a number for each in range 10. > > This I did however I also get a list of None. I don't understand where > none comes from. Can you please clarify? You get None

Re: Generator comprehension - list None

2016-10-18 Thread Ben Finney
Sayth Renshaw writes: > This I did however I also get a list of None. I don't understand where > none comes from. Can you please clarify? Every function in Python, if it returns, returns a value. In an expression that consists of only a function call, the expression

Re: Generator comprehension - list None

2016-10-18 Thread Bob Gailer
On Oct 18, 2016 7:45 AM, "Sayth Renshaw" wrote: > > I was solving a problem to create a generator comprehension with 'Got ' and a number for each in range 10. > > This I did however I also get a list of None. I don't understand where none comes from. Can you please

Re: Generator comprehension - list None

2016-10-18 Thread Chris Angelico
On Tue, Oct 18, 2016 at 10:43 PM, Sayth Renshaw wrote: > I was solving a problem to create a generator comprehension with 'Got ' and a > number for each in range 10. > > This I did however I also get a list of None. I don't understand where none > comes from. Can you

Generator comprehension - list None

2016-10-18 Thread Sayth Renshaw
I was solving a problem to create a generator comprehension with 'Got ' and a number for each in range 10. This I did however I also get a list of None. I don't understand where none comes from. Can you please clarify? a = (print("Got {0}".format(num[0])) for num in enumerate(range(10))) #