Author jjhwoldringh
Recipients ezio.melotti, jjhwoldringh, xtreak
Date 2020-01-17.15:13:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <ebb9ee10-0f30-1706-eb8d-7edc0332ace0@ziggo.nl>
In-reply-to <1579266187.79.0.582557597002.issue39368@roundup.psfhosted.org>
Content
Op 17-01-2020 om 14:03 schreef Karthikeyan Singaravelan:
> Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:
>
> You're referencing to the same list 3 times in B. So modifying it once means all the elements referring to same object reflect the change. Make a copy of the list during append to ensure modification of one doesn't affect other. This is not a python bug.
>
> ----------
> nosy: +xtreak
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue39368>
> _______________________________________

Ah, I see! Thank you for pointing this out to me! I have been pondering 
this for days on end on what was happening here.

This behaviour of Python is very frustrating, and even if "it is not a 
bug" (I knew it!) it's very nasty, and shouldn't be. Your suggestion of 
making a copy of the list during the append saves my day! And Python itself!

I was creating a very simple program for encrypting a sentence using a 
square matrix, and expected a one hour job at most. It became days, and 
I finally created a very simple method, without a rxk matrix itself, but 
using the idea!

So, if possible, please, improve Python so that this feature doesn't 
cause these unnecessary problems. Meanwhile I retract my bug report!

To my opinion this feature of Python, having aparently same objects 
refer to the same addresses in memory, was useful in times long ago when 
memory was expensive. But now this feature is not feature at all. To my 
opinion :)

Gtsori menf egr

Jaap Woldringh
Files
File name Uploaded
code.py jjhwoldringh, 2020-01-17.15:13:06
History
Date User Action Args
2020-01-17 15:13:06jjhwoldringhsetrecipients: + jjhwoldringh, ezio.melotti, xtreak
2020-01-17 15:13:06jjhwoldringhlinkissue39368 messages
2020-01-17 15:13:06jjhwoldringhcreate