On Aug 6, 12:30 pm, "Hamilton, William " <[EMAIL PROTECTED]> wrote: > When you call f(23), the variable y within it gets created and points at > None. When f(23) exits, the y that it created gets destroyed. (Well, > goes out of scope, but even if it's not garbage collected it won't ever > come back into scope.) When you then call f(24), a new y is created > that also points to None, and disappears forever when f(24) exits. > > The values in a def statement are created when the def is executed, but > the variables are only created when the function is actually called, and > new ones are created every time the function is called. > > -- > -Bill Hamilton- Hide quoted text - > > - Show quoted text -
why isn't the y in def f (x, y = []): something garbage-collected? -- http://mail.python.org/mailman/listinfo/python-list