Re: working with pointers
- From: Rocco Moretti <roccomoretti@xxxxxxxxxx>
- Date: Tue, 31 May 2005 14:21:34 -0500
"Dave Brueck" <dave@xxxxxxxxxxxxxxxxxxx> wrote in message news:mailman.299.1117566077.18027.python-list@xxxxxxxxxxxxx
Michael wrote:
sorry, I'm used to working in c++ :-p
if i do a=2 b=a b=0 then a is still 2!?
so when do = mean a reference to the same object
Always.
and when does it mean make a copy of the object??
Never.
Michael wrote: > except numbers?? >
1) Please avoid top posting
2) '=' always makes a reference. It's just that
'b = 0' makes a *new* reference for b to 0, without changing the reference of a to 2.
b.pop() modifies the object referenced by b itself, which, since it is referenced by both a & b, means that the object referenced by a is also modified.
see also:
http://starship.python.net/crew/mwh/hacks/objectthink.html .
- References:
- working with pointers
- From: Michael
- Re: working with pointers
- From: Steven Bethard
- Re: working with pointers
- From: Michael
- Re: working with pointers
- From: Dave Brueck
- Re: working with pointers
- From: Michael
- working with pointers
- Prev by Date: Re: Stupid Newbie Question Concerning CGI and Reading Forward Slashes
- Next by Date: Re: working with pointers
- Previous by thread: Re: working with pointers
- Next by thread: Re: working with pointers
- Index(es):