Re: [Python-ideas] parameter omit

Could easily incorporate, as shown here. #sample function with default args def f( a,b=None,c='abc' ): print a,b,c #customizer default= object() def call_wrapper( callable, *args, **kwargs ): args=list(args) for i,j in enumerate( args ): if j is default: offset= callable.func_code.co_argcount-\ len(callable.func_defaults) args[i]= callable.func_defaults[i-offset] return callable( *args,**kwargs ) #the uniform calls call_wrapper( f,0,default,'def' ) call_wrapper( f,0,'somebody',default ) -----Original Message----- From: Aaron Brady [mailto:castironpi@comcast.net] Sent: Wednesday, May 09, 2007 4:56 PM To: 'Aaron Brady'; 'Josiah Carlson'; 'python-ideas@python.org' Subject: RE: [Python-ideas] parameter omit You can almost do, b=f.func_defaults[1], but you still have to know where the defaults start. Very small what I'm missing. -----Original Message----- From: python-ideas-bounces@python.org [mailto:python-ideas-bounces@python.org] On Behalf Of Aaron Brady Sent: Wednesday, May 09, 2007 4:50 PM To: 'Josiah Carlson'; python-ideas@python.org Subject: Re: [Python-ideas] parameter omit No, still not uniform. Cases might be rare, even syntactic sugar maybe. if something huge: b=<def> more huge if something else: b=mything still more f(a,b,c). -----Original Message----- From: Josiah Carlson [mailto:jcarlson@uci.edu] Sent: Wednesday, May 09, 2007 4:51 PM To: Aaron Brady; python-ideas@python.org Subject: Re: [Python-ideas] parameter omit "Aaron Brady" <castironpi@comcast.net> wrote:
Actually, I wanted a uniform way to call f. f(a,b,c) for both cases if b can equal <def>.
f(a, b=...) #default c f(a, c=...) #default b - Josiah
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
participants (1)
-
Aaron Brady