Re: [noob question] References and copying

2006-07-04 Thread Petr Prikryl
"zefciu" wrote in message news:[EMAIL PROTECTED] > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. I thought I understand > it, but I have just typed in following commands: > > >>> a=[[1,2],[3,4]] > >>> b=a[1] > >>> b=[5,6] > >>

Re: References and copying

2006-06-09 Thread [EMAIL PROTECTED]
> Please verify before asserting: > > >>> a = [[1, 2], [3, 4]] > >>> b = a[1] > >>> b is a[1] > True > >>> id(b) > 46912496915448 > >>> id(a[1]) > 46912496915448 Right, I must have had slicing on the brain. -- http://mail.python.org/mailman/listinfo/python-list

Re: References and copying

2006-06-09 Thread Donn Cave
In article <[EMAIL PROTECTED]>, bruno at modulix <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: ... > >>And I don't understand it. I thought, that b will be a reference to a, > >>so changing b should change a as well. > > > > > > No, you've set the name b to reference a slice of a. Slici

Re: References and copying

2006-06-09 Thread bruno at modulix
[EMAIL PROTECTED] wrote: >>Where can I find a good explanation when does an interpreter copy the >>value, and when does it create the reference. > > Any good Python book. I have Learning Python and Programming Python 2nd > edition and they are very good IMO. > > >>I thought I understand >>it, bu

Re: [noob question] References and copying

2006-06-09 Thread bruno at modulix
zefciu wrote: > Hello! > > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. Unless you explicitely ask for a copy (either using the copy module or a specific function or method), you'll get a reference. > I thought I understan

Re: References and copying

2006-06-09 Thread [EMAIL PROTECTED]
> Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. Any good Python book. I have Learning Python and Programming Python 2nd edition and they are very good IMO. > I thought I understand > it, but I have just typed in following comm

Re: [noob question] References and copying

2006-06-09 Thread Steve Holden
zefciu wrote: > Hello! > > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. I thought I understand > it, but I have just typed in following commands: > > a=[[1,2],[3,4]] b=a[1] b=[5,6] a > > [[1, 2], [3, 4]] >

Re: [noob question] References and copying

2006-06-09 Thread Boris Borcic
zefciu wrote: > Hello! > > Where can I find a good explanation when does an interpreter copy the > value, and when does it create the reference. I thought I understand > it, but I have just typed in following commands: > a=[[1,2],[3,4]] b=a[1] b=[5,6] a > [[1, 2], [3, 4]] >>>

[noob question] References and copying

2006-06-09 Thread zefciu
Hello! Where can I find a good explanation when does an interpreter copy the value, and when does it create the reference. I thought I understand it, but I have just typed in following commands: >>> a=[[1,2],[3,4]] >>> b=a[1] >>> b=[5,6] >>> a [[1, 2], [3, 4]] >>> b [5, 6] And I don't understan