Re: working with pointers
- From: Ivan Van Laningham <ivanlan@xxxxxxxxxxxx>
- Date: Tue, 31 May 2005 13:09:01 -0600
Hi All--
Dave Brueck wrote:
>
> 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.
>
To which I would add (without attempting to preserve Dave's admirable
brevity):
a=[3,5,6]
b=a
"b" is a reference to a; both b and a are names bound to "[3,5,6]".
a=[3,5,6]
b=a[:]
a and b are now bound to different instances of [3,5,6]
Metta,
Ivan
----------------------------------------------
Ivan Van Laningham
God N Locomotive Works
http://www.andi-holmes.com/
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps: Cu Chi, Class of '70
Author: Teach Yourself Python in 24 Hours
.
- References:
- working with pointers
- From: Michael
- Re: working with pointers
- From: Steven Bethard
- Re: working with pointers
- From: Michael
- working with pointers
- Prev by Date: Re: working with pointers
- Next by Date: Re: working with pointers
- Previous by thread: Re: working with pointers
- Next by thread: Re: working with pointers
- Index(es):