print is not a function
Marc Boeren
M.Boeren at guidance.nl
Thu Oct 9 07:49:11 EDT 2003
Hi,
> > for x in my_list: print x
> I am yet convinced, this is the best solution for printing a
> simple list
> But what, if I have a condition on the list.
> Everyone tries to keep me away from list-comprehension :-)
sortof: how about
for goodx in [x for x in my_list if x.startswith('QA')]: print goodx
[listcomprehensions side-effects]
> Maybe I do not understand potential problems from side-effects, which
> I do not see in *this* case.
I don't think there are really any problems with just using the side-effects
of a list comprehension, it's just that the casual observer of the code will
have to look a bit better before noticing that it _is_ about the
side-effects: 'for x in my_list: print x' is very clear in exactly what it
performs.
Cheerio, Marc.
More information about the Python-list
mailing list