Re: a python pitfall

2015-05-14 Thread Steven D'Aprano
On Fri, 15 May 2015 04:06 am, Billy Earney wrote: > Hello friends: > > I saw the following example at > http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments > and > did not believe the output produced and had to try it for myself > > def foo(a,b,c=[]): > c.

Re: a python pitfall

2015-05-14 Thread Mark Lawrence
On 14/05/2015 19:06, Billy Earney wrote: Hello friends: I saw the following example at http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments Thanks for this link, the title "Engineering Fantasy" could have been made for the troll who's just arrived back here afte

Re: a python pitfall

2015-05-14 Thread Ian Kelly
On Thu, May 14, 2015 at 12:06 PM, Billy Earney wrote: > Hello friends: > > I saw the following example at > http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments > and did not believe the output produced and had to try it for myself See also https://docs.python.

Re: a python pitfall

2015-05-14 Thread Skip Montanaro
> I saw the following example at > http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments > and did not believe the output produced and had to try it for myself Pylint (and perhaps other Python "linters") would, I think, warn you that you were using a mutable objec

a python pitfall

2015-05-14 Thread Billy Earney
Hello friends: I saw the following example at http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments and did not believe the output produced and had to try it for myself def foo(a,b,c=[]): c.append(a) c.append(b) print(c) foo(1,1) foo(1,1) foo(1,1) p