[Python-ideas] op-assign in function argument

Calvin Spealman ironfroggy at gmail.com
Wed Feb 24 14:34:24 CET 2010


On Wed, Feb 24, 2010 at 1:23 AM, wxyarv <weasley_wx at qq.com> wrote:
> has anybody thought the op-assign in function argument is a good idea? now
> we can use parameter name to specifie argument, like this:
>
> def foo(arg1): pass
>
> # call
> foo(arg1 = "bar")
>
> but, if function has default parameter, it will be inconvenience:
> def foo_with_long_defualts(arg1 = we | are | default | flags | set): pass
>
> # call
> foo_with_long_defaults(arg1 = we | are | default | flags | set |
> another_flags)
>
> so, why not add op-assign support in named argument?
>
> foo_with_long_defaults(arg1 |= another_flags)

If you wan to do this, you can just support it in the function
yourself. That is, if the function wants to take an additional_flags
parameter, it should. I don't think the complications this could add
to the call syntax are good. It becomes a form of
assignment-as-an-expression and makes the call harder to parse (by
human eyes).

> are there anybody has the same idea with me?

-1

> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy



More information about the Python-ideas mailing list