I am out of trial and error again Lists

Rustom Mody rustompmody at gmail.com
Sat Oct 25 01:55:59 EDT 2014


On Saturday, October 25, 2014 11:20:03 AM UTC+5:30, Chris Angelico wrote:
> On Sat, Oct 25, 2014 at 4:40 PM, Rustom Mody  wrote:
> > Its generally accepted that side-effecting functions are not a good idea
> > -- typically a function that returns something and changes global state.
> 
> Only in certain circles. Not in Python. There are large numbers of
> functions with side effects (mutator methods like list.append,
> anything that needs lots of state like random.random, everything with
> external effect like I/O, heaps of stuff), and it is most definitely
> not frowned upon.
> 
> In Python 3 (or Python 2 with the future directive), print is a
> function, print() an expression. It's not "semantically a statement".

Ok
So give me a valid (ie useful) use where instead of the usual
l=[1,2,3]
l.append(4)

we have

foo(l.append(4))




More information about the Python-list mailing list