About calling syntax
Talin wrote:
However, to address the OP's question, do this instead: foo = \ Foo(x=1, y=2)( Foo(x=4, y=5)( Foo(x=3,y=4)(), Foo(x=5,y=6)()) ) )
I use this form in my real coding. Georg Brandl wrote:
However, exchanging poisitional and keyword arguments is not in the scope of the PEP, and isn't likely to have any future at all -- it's just too ambiguous when the called object has named arguments instead of a catch-all *args in its signature. More precisely I asked about the following thing.
Let def foo(*args, **kw): ... So in call: foo(x=2,y=3, a,b,c) args = [a,b,c] and kw = {'x':2, 'y':3} in call: foo(a,b,c, x=2, y=3) args = [a,b,c] and kw = {'x':2, 'y':3} too. It's just simmetrical form of calling syntax. Best regards, Zaur
On Tue, Sep 9, 2008 at 11:22 PM, Zaur Shibzoukhov
in call: foo(x=2,y=3, a,b,c) args = [a,b,c] and kw = {'x':2, 'y':3}
in call: foo(a,b,c, x=2, y=3) args = [a,b,c] and kw = {'x':2, 'y':3} too.
It's just simmetrical form of calling syntax.
But why should you be forced to separate them like that. Why not foo(a,x=2,b,y=3,c,z=4) args = [a,b,c] and kw = {'x':2, 'y':3, 'z':4} I'm sure there are scenarios where this is useful but I think in general it would be less readable. As it is, I can't miss a positional argument in the middle of a long list of keyword arguments: foo(a=b,c=d,e=f,g=h,i=j,k=l,m) --- Bruce
participants (2)
-
Bruce Leban
-
Zaur Shibzoukhov