extend behaviour of assignment operator

Guenther Sohler guenther.sohler at gmail.com
Tue Jan 9 02:14:31 EST 2024


Hi,

when i run this code

a = cube([10,1,1])
b = a

i'd like to extend the behaviour  of the assignment operator
a shall not only contain the cube, but  the cube shall also know which
variable name it
was assigned to, lately. I'd like to use that for improved user interaction.

effective code should be:

a=cube([10,1,1])
a.name='a'

b=a
b.name='b' # i am aware that a.name also changes


can decorators also be used with assignment operators ?

thank you for your hints


More information about the Python-list mailing list