In article <[email protected]>, Steven D'Aprano <[email protected]> wrote:
> On Thu, 20 Jun 2013 09:19:48 -0400, Roy Smith wrote: > > > In article > > <[email protected]>, > > rusi <[email protected]> wrote: > > > >> > > def f(a, L=[]): > >> > > Â Â L.append(a) > >> > > Â Â return L > > > >> Every language has gotchas. This is one of python's. > > > > One of our pre-interview screening questions for Python programmers at > > Songza is about this. I haven't been keeping careful statistics, but > > I'd guess only about 50% of the candidates get this right. > > > What exactly is the question? Because it's not always a bug to use a > mutable default, there are good uses for it: It's a screening question; I'd rather not reveal all the details (it's really annoying when you find your screening questions posted to stack overflow). But, yes, I understand that there are good uses.
-- http://mail.python.org/mailman/listinfo/python-list
