Why python doesn't use syntax like function(, , x) for default parameters?

Terry Hancock hancock at anansispaceworks.com
Fri Mar 10 06:38:34 EST 2006


On 10 Mar 2006 09:51:01 GMT
Duncan Booth <duncan.booth at invalid.invalid> wrote:
> Dmitry Anikin wrote:
> > Is there some contradiction in python syntax which
> > disallows an easy implementation of this feature, or
> > just nobody bothered with this? If former is the case,
> > please show me why, because I badly need this feature in
> > embedded python app (for compatibility with other
> > language that uses such syntax) and might venture to
> > implement it myself, so don't want to waste time if it's
> > gonna break something.
> > 
> I think you would find it hard to implement exactly that
> in Python. Of  course what you can do easily enough is
> invent a magic 'missing' value and  map Python calls of:
> 
>    a_func(missing, missing, 3)
> 
> to a call of:
> 
>    a_func(,,3)

It's not uncommon, of course, to use "None" for this
purpose. I have a lot of code that does something like:

def myfunc(a, b, c):
    if a is None:
        a = []
    ...


-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com




More information about the Python-list mailing list