Default parameters

Georgy Pruss see_signature__ at hotmail.com
Sun Dec 21 21:21:52 EST 2003


"Terry Reedy" <tjreedy at udel.edu> wrote in message news:zuydnUQutOGWT3iiRVn-gQ at comcast.com...
|
| "Bengt Richter" <bokr at oz.net> wrote in message
| news:bs1lov$3vu$0 at 216.39.172.122...
| > That's useful, but IMO not the optimal syntax,
| because cache here is really not
| > being used as a parameter. That's why I would
| like a way to bind locals similarly
| > without being part of the calling signature.
| E.g.,
| >
| > def _tento(n)(
| >     # preset bindings evaluated here at def-time
| >     cache={}
| > ):
| >     try:
| >         return cache[n]
| >     except KeyError:
| >         answer = cache[n] = 10L ** n
| >         return answer
|
| I have also thought of using a ';' as in
| def _tento(n; cache = {}):
|   [etc]
|
| to indicate a def-time initialized  non-parameter.
|
| Terry J. Reedy

It's getting more and more cryptic. Why not clearly say 'const' for an
object that's not going to change and 'static' for an object that
is ...uhm.. static?

--
Georgy






More information about the Python-list mailing list