[Python-ideas] fixing mutable default argument values
Jim Jewett
jimjjewett at gmail.com
Thu Jan 18 23:12:52 CET 2007
On 1/18/07, George Sakkis <gsakkis at rutgers.edu> wrote:
> On 1/18/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> > But he actually ones a variable that *does* keep state between calls
> > (like a mutable default arg), but can't be overridden.
> > For What Its Worth, my personal opinion is that having to create an
> > object instead of a function is annoying, but not so bad (or so
> > frequent) that it is worth special syntax.
> Function attributes fit the bill really good if writing a class is too
> much overhead.
Not really, because Python doesn't have the equivalent of "this". The
only way for a function to access its own attributes is to hardcode a
name and to assume the name will always refer to that same function
object.
In practice, it mostly works, but so does just using a global variable.
-jJ
More information about the Python-ideas
mailing list