Augmented Assignement (was: Re: PEP scepticism)

Roman Suzi rnd at onego.ru
Fri Jun 29 12:39:48 EDT 2001


On 29 Jun 2001, Bernhard Herzog wrote:

>"Alex Martelli" <aleaxit at yahoo.com> writes:
>
>> "Bernhard Herzog" <bh at intevation.de> wrote in message
>> news:6qn16r7i69.fsf at abnoba.intevation.de...
>> > I think the main problem (in as much as there actually is a problem) is
>> > that whether augmented assignment rebinds the left hand side depends on
>> > the type of object, i.e. whether the object implements the appropriate
>>
>> Right!  I think the main advantage (in as much as there actually is an
>> advantage) is that whether augmented assignment rebids the left hand
>> side depends on the type of object. i.e. whether the object implements
>> the appropriate methods.  This is called *polymorphism* and is a concept
>> of *HUGE* power.
>
>Well, polymorphism is certainly very important and powerful in python
>but in an of itself that's no argument in favor of the intricacies of
>augmented assignment in Python. Just because something could depend on
>the types of the objects involved doesn't mean that it should.

In fact, many things depend on the type of the objects. Types of the
objects define what operation will be done. For example, in a simple

A = A + 1

+ operation is different for different A type. It is inevitable that not
everything is written every time. Everything could not be explicit
in any place.

>Augmented assignment doesn't actually offer anything that couldn't have
>been done with explicit method calls,

They do. Some operations are better defined in terms of "+=".
For example, list.append()


Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Friday, June 29, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "I failed attitude in school." _/





More information about the Python-list mailing list