Re: Bizarre method keyword-arg bug.



Fredrik Lundh wrote:

default argument values are evaluated when the function object is created (by the "def" statement, that is), not when the resulting function is called. if you mutate the default values, the mutations will stick.

and yes, workarounds and further details are provided here:

http://effbot.org/zone/default-values.htm

</F>

.



Relevant Pages

  • Re: Why are tuples immutable?
    ... > were people work with mutable objects but don't wish to mutate specific ... > Demanding that users of dictioanaries somehow turn their mutable objects ... A dict key doesn't *really* need to be immutable. ... def __init__: ...
    (comp.lang.python)
  • Re: Dynamically calling a certain set of methods
    ... def new_create ... puts "XELLO" ... because the derived class won't see the parent's @mutations. ...
    (comp.lang.ruby)
  • Re: Lizard engines and rat engines
    ... > elephant species chooses to mutate, but that it mutates as all species do, ... > randomly, and those mutations which are rewarded, over a long succession ... reward, punish or tolerate. ...
    (sci.bio.evolution)
  • Re: Sorting Multidimesional array(newbie)
    ... Fredrik Lundh wrote: ... def myListCmp: ... compares or mappings, would work as well as the fancier alternatives... ...
    (comp.lang.python)
  • Re: Bacteria Planned Mutations?
    ... mutations at a rate about 100 million times greater than would be ... dissected the genes of these mutated bacteria by sequencing them, ... mutations supposedly worked only on that part of the chromosome. ... There are computer viruses built to "randomly mutate" a few lines ...
    (sci.bio.evolution)