scope of optional arguments

Steven Clark steven.p.clark at gmail.com
Mon May 19 10:38:18 EDT 2008


http://www.ferg.org/projects/python_gotchas.html#contents_item_6

On Mon, May 19, 2008 at 10:30 AM, cseja <p5secr2 at uni-jena.de> wrote:
> If I call
>
> print walk([1,2,3], [])
> print walk([5,6,7])
>
> I get
>
> [1, 2, 3]
> [4, 5, 6]
>
> but when I call
>
> print walk([1,2,3])
> print walk([5,6,7])
>
> I get
>
> [1, 2, 3]
> [1, 2, 3, 4, 5, 6]
>
> at stdout, where
>
> def walk(seq, result = []):
>  for item in seq:
>    result.append(item)
>  return result
>
> Does that mean that the scope of optional arguments is global if they aren't
> used and local if they are (or am I missing something here)?
>
> Regards,
> CS
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list