Re: why i have the output of [None, None, None]

2014-04-10 Thread Terry Reedy
it.strip() !=""] Don't use comprehensions for side effects. To get what you want, just write normal code. for it in x: if it.strip() != '': print('ok') ok ok ok [None, None, None] i understand there are three 'ok' in the output,but why i have the output of [None, None, None] Reread the ref manual section on comprehensions. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: why i have the output of [None, None, None]

2014-04-10 Thread Johannes Schneider
>>> [print("ok") for it in x if it.strip() !=""] ok ok ok [None, None, None] i understand there are three 'ok' in the output,but why i have the output of [None, None, None] -- Johannes Schneider Webentwicklung johannes.schnei...@galileo-press.d

Re: why i have the output of [None, None, None]

2014-04-10 Thread Jussi Piitulainen
length power writes: > >>> x=['','x1','x2','x3',' '] > >>> x > ['', 'x1', 'x2', 'x3', ' '] > >>> [print("ok") for it in x if it.strip() !="

Re: why i have the output of [None, None, None]

2014-04-10 Thread Rustom Mody
This is called imperative programming: for it in x: ... if it.strip() != '': ...print ("Ok") This is called functional programming: >>> [y for y in x if y.strip() != ''] ['x1', 'x2', 'x3'] What you have is a confusion: print is imperative comprehension is functional You should not mix

Re: why i have the output of [None, None, None]

2014-04-10 Thread Skip Montanaro
7;x2','x3',' '] >>>> x > ['', 'x1', 'x2', 'x3', ' '] >>>> [print("ok") for it in x if it.strip() !=""] > ok > ok > ok > [None, None, None] > > i understand there

why i have the output of [None, None, None]

2014-04-10 Thread length power
>>> x=['','x1','x2','x3',' '] >>> x ['', 'x1', 'x2', 'x3', ' '] >>> [print("ok") for it in x if it.strip() !=""] ok ok ok [None, None, None] i understand there are three 'ok' in the output,but why i have the output of [None, None, None] -- https://mail.python.org/mailman/listinfo/python-list