c[:]()

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Jun 3 22:03:25 CEST 2007


In <1180886141.096451.68060 at k79g2000hse.googlegroups.com>,
Stebanoid at gmail.com wrote:
>>> [using `map()`]
>> And has the same issue as a list comprehension if all you want is the side
>> effect of the calls: a useless temporary list full of `None`\s is build.
> 
> functoins can return a values, and you get it. I don't think that it
> is bad side effect.

I don't either.  By definition it's not a side effect at all. Side effects
are the "things that happen" besides the return values.

Warren Stringer wanted to call the functions just for the side effects
without interest in the return values.  So building a list of return
values which is immediately thrown away is a waste of time and memory.

> When you write simple
>>>> def a(): print "From Russia with love."
>>>> a()
> you have side effect too - returning "None".

No, the side effect is the printing of 'From Russia with love.'

IMHO there's a difference between this single `None` that can't be
prevented and abusing a list comprehension or `map()` just for side
effects and not for building a list with meaningful content.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list