What are the differences between _weak_ references and "normal" references?
Gerhard Häring
gh at ghaering.de
Fri Apr 4 12:22:05 EST 2003
sdieselil <sdieselil at yahoo.com> wrote:
> Hi
>
> I noticed a module weakref in Python standard library. What is weak
> reference and in what way it differs from "normal" reference?
Not that I fully understand it myself, but have you looked into the module
documentation for weakref and/or http://www.python.org/peps/pep-0205.html
yet?
>By the way, how can I implement usual reference in Python (I mean C++
>reference)?
::ASSIGN REFERENCE::
C++:
Foo foo1("foo1");
Foo& foo2 = foo1;
Python:
foo1 = Foo("foo1")
foo2 = foo1
::COPY VALUE::
C++:
Foo foo1("foo1")
Foo foo2 = foo1; // call copy constructor
Python:
import copy
foo1 = Foo("foo1")
foo2 = copy.copy(foo1)
I'm currently re-learning C++, so there may be bugs in the above C++ :-)
-- Gerhard
More information about the Python-list
mailing list