[Tutor] Question about local scopes (namespaces)

Kent Johnson kent37 at tds.net
Wed Feb 21 20:06:50 CET 2007


Adam Pridgen wrote:
> Sorry for the long email, and thanks in advance.
> 
> In the below example, is the list foo supposed to retain the value
> after the function, Bar(), returns?

Yes

> Is the list foo supposed to reinitialized on each call to Bar(),
> meaning len(foo) == 0, and when Bar() returns len(foo) (when Bar() is
> called w/out parameters)?

No. See
http://www.effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm

Kent



More information about the Tutor mailing list