Re: DRY functions with named attributes used as default arguments

2011-10-09 Thread Tim Chase
On 10/09/11 10:37, Steven D'Aprano wrote: My intent is to have a function object something like def foo(arg1, arg2=foo.DEFAULT): return int(do_stuff(arg1, arg2)) foo.SPECIAL = 42 foo.MONKEY = 31415 foo.DEFAULT = foo.SPECIAL What's the purpose of having both foo.SPECIAL an

Re: DRY functions with named attributes used as default arguments

2011-10-09 Thread Steven D'Aprano
Tim Chase wrote: > My intent is to have a function object something like > >def foo(arg1, arg2=foo.DEFAULT): > return int(do_stuff(arg1, arg2)) >foo.SPECIAL = 42 >foo.MONKEY = 31415 >foo.DEFAULT = foo.SPECIAL What's the purpose of having both foo.SPECIAL and foo.DEFAULT? Yo

Re: DRY functions with named attributes used as default arguments

2011-10-09 Thread Arnaud Delobelle
On 9 October 2011 13:20, Tim Chase wrote: > My intent is to have a function object something like > >  def foo(arg1, arg2=foo.DEFAULT): >    return int(do_stuff(arg1, arg2)) >  foo.SPECIAL = 42 >  foo.MONKEY = 31415 >  foo.DEFAULT = foo.SPECIAL > > so I can call it with either > >  result = foo(my

DRY functions with named attributes used as default arguments

2011-10-09 Thread Tim Chase
My intent is to have a function object something like def foo(arg1, arg2=foo.DEFAULT): return int(do_stuff(arg1, arg2)) foo.SPECIAL = 42 foo.MONKEY = 31415 foo.DEFAULT = foo.SPECIAL so I can call it with either result = foo(myarg) or result = foo(myarg, foo.SPECIAL) However I