Message360195
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 |
File name |
Uploaded |
code.py
|
jjhwoldringh,
2020-01-17.15:13:06
|
|
Date |
User |
Action |
Args |
2020-01-17 15:13:06 | jjhwoldringh | set | recipients:
+ jjhwoldringh, ezio.melotti, xtreak |
2020-01-17 15:13:06 | jjhwoldringh | link | issue39368 messages |
2020-01-17 15:13:06 | jjhwoldringh | create | |
|