indirect references

Rainer Deyke root at rainerdeyke.com
Mon Jun 5 19:51:53 EDT 2000


<shaleh at debian.org> wrote in message news:8hha1n$phl$1 at nnrp1.deja.com...
> How do I do this in python:
>
> foo = 'string'
> bar = foo
>
> somehow assign to bar and change the value of foo.

This is probably the closest you'll get:

class Reference:
  def __init__(self, it):
    self.target = it

foo = Reference('string')
bar = foo
bar.target = 'another string'
print foo.target


--
Rainer Deyke (root at rainerdeyke.com)
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list