op-assign in function argument

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) are there anybody has the same idea with me?

On Wed, Feb 24, 2010 at 1:23 AM, wxyarv <weasley_wx@qq.com> wrote:
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
-- 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

Calvin Spealman wrote:
Even better is to just give the default args a name: FOO_DEFAULTS = we | are | default | flags | set def foo(arg=FOO_DEFAULTS): ... my_flags = FOO_DEFAULTS | other_flags foo(arg=my_flags) (Also -1 on this syntax idea - simply giving the default value a name is a much simpler and more obvious approach) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------

On Wed, Feb 24, 2010 at 1:23 AM, wxyarv <weasley_wx@qq.com> wrote:
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
-- 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

Calvin Spealman wrote:
Even better is to just give the default args a name: FOO_DEFAULTS = we | are | default | flags | set def foo(arg=FOO_DEFAULTS): ... my_flags = FOO_DEFAULTS | other_flags foo(arg=my_flags) (Also -1 on this syntax idea - simply giving the default value a name is a much simpler and more obvious approach) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------
participants (3)
-
Calvin Spealman
-
Nick Coghlan
-
wxyarv