<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Well well well, <br>
<br>
lots of interesting points have flowed there, I won't have any chance
of reacting to each one ^^<br>
<br>
<blockquote type="cite">>And no one seemed to enjoy the
possibilities of getting "potentially static variables" this way.
  <br>
</blockquote>
>You did not search hard enough.
<br>
<br>
Would anyone mind pointing me to people that have made a sweet use of
mutable default arguments ?<br>
At the moment I've only run into "memoization" thingies, which looked
rather awkward to me : either the "memo" has to be used from elsewhere
in the program, and having to access it by browsing the "func_defaults"
looks not at all "KISS", or it's really some private data from the
function, and having it exposed in its interface is rather error-prone.<br>
<br>
<br>
<blockquote cite="mid:200905092132.36438.steve@pearwood.info"
 type="cite">
  <pre wrap="">[...]
  </pre>
  <blockquote type="cite">
    <pre wrap="">Does it exist ? Do we have any way, from inside a call block, to
browse the default arguments that this code block might receive ?
    </pre>
  </blockquote>
  <pre wrap="">[...]

dir(func_object) is your friend :)

  </pre>
</blockquote>
Whoups, I meant "from inside a *code* block" :p<br>
But that's the "self function" thread you noted, I missed that one...
thanks for pointing it ^^<br>
<br>
<br>
<blockquote cite="mid:200905092132.36438.steve@pearwood.info"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">On the other hand, would anyone support my alternative wish, of
having a builtin "NotGiven", similar to "NotImplemented", and
dedicated to this somehow usual taks of "placeholder" ?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
There already is such a beast: None is designed to be used as a 
placeholder for Not Given, Nothing, No Result, etc. 

If None is not suitable, NotImplemented is also a perfectly good 
built-in singleton object which can be used as a sentinel. It's already 
used as a sentinel for a number of built-in functions and operators. 
There's no reason you can't use it as well.

  </pre>
</blockquote>
Well, to me there was like a ternary semantic for arguments :<br>
*None -> make without this argument / don't use this feature<br>
*"NotGiven" -> create the parameter yourself<br>
*"Some value" -> use this value as a parameter<br>
But after reflexion, it's quite rare that the three meanings have to be
used in the same place, so I guess it's ok like it is...<br>
<br>
Even though, still, I'd not be against new, more explicit builtins.
"None" has too many meanings to be "self documenting", and I feel
"NotImplemented" doesn't really fit where we mean "notGiven"<br>
That's the same thing for exceptions : I've seen people forced to make
ugly workarounds because they got "ValueError" where they would have
loved to get "EmptyIterableError" or other precise exceptions.<br>
But maybe I'm worrying on details there :p<br>
<br>
<blockquote cite="mid:200905092132.36438.steve@pearwood.info"
 type="cite">
  <pre wrap="">Heh heh heh, he thinks beginners read manuals :-)

  </pre>
</blockquote>
 ^^ I'm maybe the only one, but I've always found the quickest way to
learn
a language/library was to read the doc. <br>
Wanna learn python ? Read the
language reference, then the library reference. Wanna know what's the
object model of PHP5 versus PHP4 ? Read the 50 pages chapter on that
matter. Wanna play with Qt ? Read the class libraries first. :p<br>
Good docs get read like novels, and it's fun to cross most of the
gotchas
and implementation limitations without having to be biten by them
first. People might have the feeling that they gain time by jumping to
the practice, I've rather the feeling that they lose hell a lot of it,
that way.<br>
<br>
<br>
<br>
Back to the "mutable default arguments" thingy :<br>
I think I perfectly see the points in favor of having them as
attributes of the function method, as it's the case currently. <br>
It does make sense in many ways, even if less sense than "class
attributes", for sure (the object model of python is rock solid to me,
whereas default arguments are on a thin border that few languages had
the courage to explore - most of them forbidding non-litteral
constants).<br>
<br>
But imo, it'd be worth having a simple and "consensual way" of
obtaining dynamic evaluation of default arguments, without the "if
arg==none:" pattern.<br>
The decorators that people have submitted have sweet uses, but they
either deepcopy arguments, use dynamic evaluation of code strings, or
force to lamba-wrap all arguments ; so they're not equivalent to what
newbies would most of the time expect - a reevaluation of the python
code they entered after '='.<br>
<br>
So the best, imo, would really be a keyword or some other form that
reproduces with an easy syntax the "lambda-wrapping" we had.<br>
<br>
If adding keywords is too violent, what would you people think of some
notation similar to what we already have in the "function arguments
world ", i.e stars ?<br>
<br>
def func(a, c = *[]):<br>
    pass<br>
<br>
Having 1, 2 or 3 stars in the "default argument" expression, wouldn't
it be OK ? I guess they have no meaning there at the moment, so we
could give them one : "keep that code as a lamda functio nand evaluate
it at each function call".<br>
Couldn't we ?<br>
The risk would be confusion with the other "*" and "**", but in this
case we might put 3 stars (yeah, that's much but...).<br>
<br>
Any comment on this ?<br>
<br>
Regards, <br>
Pascal<br>
<br>
PS : Has anyone read Dale Carneghie's books here ? That guy is a genius
of social interactions, and I guess that if 1/3 of posters/mailers had
read him, there would never be any flame anymore on forums and mailing
lists.<br>
Contrarily to what his titles might look like, he doesn't promote
hypocrisy or cowardness ; he simply points lots of attitudes (often
unconscious) that ruin discussions without helping in any way the
matter go forward.<br>
I'm myself used to letting scornful or aggressives sentences pass by ;
but others don't like them, and I fully understand why. <br>
So could't we smoothen edges, in order to keep the discusion as it's
supposed to be - a harmless sharing of pros and cons arguments, which
endangers no one's life - instead of having it randomly turned into a
confrontation of egos, pushing each other down as in an attempt not to
drown ?<br>
<a class="moz-txt-link-freetext" href="http://en.wikipedia.org/wiki/How_to_Win_Friends_and_Influence_People">http://en.wikipedia.org/wiki/How_to_Win_Friends_and_Influence_People</a><br>
<br>
<br>
<br>
</body>
</html>