On 8/25/11 1:54 PM, t...@thsu.org wrote:
> On Aug 25, 10:35 am, Arnaud Delobelle wrote:
>> You're close to the usual idiom:
>>
>> def doSomething(debug=None):
>> if debug is None:
>> debug = defaults['debug']
>> ...
>>
>> Note the use of 'is' rather than '=='
>> HTH
>
> Hmm, from
On Thursday, August 25, 2011 1:54:35 PM UTC-7, ti...@thsu.org wrote:
> On Aug 25, 10:35 am, Arnaud Delobelle wrote:
> > You're close to the usual idiom:
> >
> > def doSomething(debug=None):
> > if debug is None:
> > debug = defaults['debug']
> > ...
> >
> > Note the use of 'is' rat
On Fri, Aug 26, 2011 at 6:54 AM, wrote:
> def doSomething(debug=None):
> debug = coalesce(debug,defaults['debug'])
> # blah blah blah
>
It won't work with a True/False flag, but if you can guarantee that
all real options will evaluate as True, you can use a simpler
notation:
def doSomething(o
On Aug 25, 10:35 am, Arnaud Delobelle wrote:
> You're close to the usual idiom:
>
> def doSomething(debug=None):
> if debug is None:
> debug = defaults['debug']
> ...
>
> Note the use of 'is' rather than '=='
> HTH
Hmm, from what you are saying, it seems like there's no elegant wa
On 25/08/2011 15:30, t...@thsu.org wrote:
What is the most common way to handle default function arguments that
are set at run time, rather than at compile time? The snippet below is
the current technique that I've been using, but it seems inelegant.
defaults = { 'debug' : false }
def doSomethin
On Aug 25, 3:30 pm, t...@thsu.org wrote:
> What is the most common way to handle default function arguments that
> are set at run time, rather than at compile time? The snippet below is
> the current technique that I've been using, but it seems inelegant.
>
> defaults = { 'debug' : false }
> def do
What is the most common way to handle default function arguments that
are set at run time, rather than at compile time? The snippet below is
the current technique that I've been using, but it seems inelegant.
defaults = { 'debug' : false }
def doSomething (debug = None):
debug = debug if debug