Scope rule pecularities

Antoon Pardon apardon at forel.vub.ac.be
Wed May 12 07:23:04 EDT 2004


Op 2004-05-10, Greg Ewing schreef <greg at cosc.canterbury.ac.nz>:
> Antoon Pardon wrote:
>> IMO having operators that should work in place for object that
>> are immutable, sound contradictory. Having the following code:
>
> But restricting += etc. to work only on mutables would
> mean you wouldn't be able to do things like
>
>    x = 42
>    x += 1
>
> which is a very handy thing to be able to do.

But it creates confusions because the semantics
is not consistent.

IMO lacking an assignment that copies the value
of one object into another was a mistake and
which creats IMO a lot of difficulties.

If I have a function with an object as a paramter.
and this object is mutable. Now within this function
I find a second object with the value I want the
argument to have. Now I can't simply copy the
second object over the argument but I have to
copy attribute by attribute from the second object
into the argument.

-- 
Antoon Pardon



More information about the Python-list mailing list