Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Neal Becker
Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and attribute references (x.a) represent locations. Function calls represent

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Guido van Rossum
On 8/11/06, Neal Becker [EMAIL PROTECTED] wrote: Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and attribute references

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Martin v. Löwis
Neal Becker schrieb: No. Array references (x[i]) and attribute references (x.a) represent locations. Function calls represent values. This is no different than the distinction between lvalues and rvalues in C. Except this syntax is valid in c++ where X() is a constructor call:

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Phillip J. Eby
At 09:40 PM 8/11/2006 +0200, Martin v. Löwis wrote: Michael Urman schrieb: On 8/9/06, Michael Hudson [EMAIL PROTECTED] wrote: The question doesn't make sense: in Python, you assign to a name, an attribute or a subscript, and that's it. Just to play devil's advocate here, why not to a

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-11 Thread Martin v. Löwis
Phillip J. Eby schrieb: Actually, this isn't as hard as you're implying. In at least the compiler.ast package, such an operation would be represented as a CallFunc node as the child of an Assign node. Wrapping the call node's main child expression in a Getattr for __setcall__ would then

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Martin v. Löwis
Neal Becker schrieb: 1) Should assignment to a temporary object be allowed? Unlike Michael, I think the question does make sense, and the answer is no, for the reason Michael gave: you assign to names, not to objects. 2) Should the syntax for creation of a temporary object be a constructor

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Josiah Carlson
Michael Urman [EMAIL PROTECTED] wrote: On 8/9/06, Michael Hudson [EMAIL PROTECTED] wrote: The question doesn't make sense: in Python, you assign to a name, an attribute or a subscript, and that's it. Just to play devil's advocate here, why not to a function call via a new __setcall__?

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread James Y Knight
On Aug 10, 2006, at 12:01 PM, Josiah Carlson wrote: Michael Urman [EMAIL PROTECTED] wrote: On 8/9/06, Michael Hudson [EMAIL PROTECTED] wrote: The question doesn't make sense: in Python, you assign to a name, an attribute or a subscript, and that's it. Just to play devil's advocate here,

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Guido van Rossum
On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and attribute references (x.a) represent locations. Function calls represent values. This is no different than

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Phillip J. Eby
At 09:24 AM 8/10/2006 -0700, Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and attribute references (x.a) represent locations.

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread James Y Knight
On Aug 10, 2006, at 12:19 PM, James Y Knight wrote: Please note I'm actually arguing for this proposal. Just agreeing that it is not a completely nonsensical idea. ERK! Big typo there. I meant to say: Please note I'm NOT*** actually arguing for this proposal. Sorry for any confusion.

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Josiah Carlson
Phillip J. Eby [EMAIL PROTECTED] wrote: At 09:24 AM 8/10/2006 -0700, Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread James Y Knight
On Aug 10, 2006, at 12:24 PM, Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references (x[i]) and attribute references (x.a) represent locations.

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Guido van Rossum
On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: On Aug 10, 2006, at 12:24 PM, Guido van Rossum wrote: On 8/10/06, James Y Knight [EMAIL PROTECTED] wrote: It makes just as much sense as assigning to an array access, and the semantics would be pretty similar. No. Array references

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Phillip J. Eby
At 12:28 PM 8/10/2006 -0700, Guido van Rossum wrote: On Aug 10, 2006, at 12:31 PM, Phillip J. Eby wrote: Honestly, it might make more sense to get rid of augmented assignment in Py3K rather than to add this. It seems that the need for something like this springs primarily from the existence

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Guido van Rossum
On 8/10/06, Phillip J. Eby [EMAIL PROTECTED] wrote: That being said, the benefit of hypergeneralizing assignment seems small compared to its price. So eliminating augmented assignment seems a more attractive way to get rid of the nuisance of the perennially repeated proposals to fix or

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread James Y Knight
On Aug 10, 2006, at 4:57 PM, Phillip J. Eby wrote: However, I'm also not clear that trying to assign to a function call *is* ill-advised. One of the things that attracted me to Python in the first place is that it had a lot of features that would be considered hypergeneralization in

[Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Neal Becker
class X (object): pass X() += 2 SyntaxError: can't assign to function call Suppose I actually had defined __iadd__ for class X. Python says this syntax is invalid. I wish is wasn't. Here's where I might use it. Suppose I have a container class. Suppose I could make a slice of this

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Josiah Carlson
Neal Becker [EMAIL PROTECTED] wrote: class X (object): pass X() += 2 SyntaxError: can't assign to function call [snip] Does anyone else think this would be a good addition to Python? No. += implies assignment. As the syntax error states, can't assign to function call. -1 -

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Terry Reedy
Neal Becker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] class X (object): pass X() += 2 SyntaxError: can't assign to function call Suppose I actually had defined __iadd__ for class X. Python says this syntax is invalid. I wish is wasn't. If you translate to x() = x()

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Michael Hudson
Neal Becker [EMAIL PROTECTED] writes: 1) Should assignment to a temporary object be allowed? The question doesn't make sense: in Python, you assign to a name, an attribute or a subscript, and that's it. Cheers, mwh -- exarkun I think there's a rather large difference between a stale

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Georg Brandl
Terry Reedy wrote: Neal Becker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] class X (object): pass X() += 2 SyntaxError: can't assign to function call Suppose I actually had defined __iadd__ for class X. Python says this syntax is invalid. I wish is wasn't. If you

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Guido van Rossum
On 8/9/06, Georg Brandl [EMAIL PROTECTED] wrote: Terry Reedy wrote: Neal Becker [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] class X (object): pass X() += 2 SyntaxError: can't assign to function call Suppose I actually had defined __iadd__ for class X. Python

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-09 Thread Georg Brandl
Guido van Rossum wrote: This is similar to x = ([1], 2) x[0] += [2] which doesn't currently work either, though it could. No it couldn't. You can't assign to x[0]. L += R is defined as L = L.__iadd__(R) so L must be a valid assignment target. Thanks for making that clear. I actually