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
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, wh
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:
>
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 function call via a
> new __setcall__?
Just try s
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 attribut
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 repr
On 8/10/06, James Y Knight <[EMAIL PROTECTED]> wrote:
> On Aug 10, 2006, at 4:57 PM, Phillip J. Eby wrote:
> > That being said, the benefit of hypergeneralizing assignment seems
> > small compared to its price.
>
> Well, it's a mostly obvious extension of an existing idea, so the
> price doesn't se
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"
Michael Urman wrote:
> Just to play devil's advocate here, why not to a function call via a
> new __setcall__?
You still haven't answered the question of what this
buys you over just giving your object a suitably
named method that does whatever your __setcall__
method would have done.
Can you sh
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
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
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
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
> "loc
"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 reference
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.
Ja
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
>"locat
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
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 dev
"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
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__? I'm not saying there's the use case to justif
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
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 cle
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 def
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 wi
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
--
I think there's a rather large difference between a stale
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
"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
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
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 con
29 matches
Mail list logo