Re: Why does python behave so? (removing list items)

2008-03-27 Thread Bruno Desthuilliers
Thomas Dybdahl Ahle a écrit : > On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote: >> Why does python create a reference here, not just copy the variable? > > Python, like most other oo languages, will always make references for =, > unless you work on native types (numbers and strings).

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Carl Banks
On Mar 26, 11:30 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 26 Mar 2008 23:12:27 +0100, Thomas Dybdahl Ahle wrote: > > On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote: > >> Why does python create a reference here, not just copy the variable? > > > Python,

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Steven D'Aprano
On Wed, 26 Mar 2008 23:12:27 +0100, Thomas Dybdahl Ahle wrote: > On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote: >> Why does python create a reference here, not just copy the variable? > > Python, like most other oo languages, will always make references for =, > unless you work on na

Re: Why does python behave so? (removing list items)

2008-03-26 Thread castironpi
On Mar 26, 5:28 pm, [EMAIL PROTECTED] wrote: > Micha³ Bentkowski: > > > Why does python create a reference here, not just copy the variable? > > I think to increase performance, in memory used and running time (and > to have a very uniform way of managing objects). > > Bye, > bearophile A variable

Re: Why does python behave so? (removing list items)

2008-03-26 Thread bearophileHUGS
Michał Bentkowski: > Why does python create a reference here, not just copy the variable? I think to increase performance, in memory used and running time (and to have a very uniform way of managing objects). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Dan Bishop
On Mar 26, 5:12 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote: > > Why does python create a reference here, not just copy the variable? > > Python, like most other oo languages, will always make references for =, > unless you work on

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Jarek Zgoda
Michał Bentkowski pisze: > Why does python create a reference here, not just copy the variable? Because Python works like that -- it uses names and values idiom. If you change value, all names will be bound to the same changed value. j=range(0,6) k=j del j[0] j > [1, 2, 3, 4,

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Waldemar Osuch
On Mar 26, 4:04 pm, "Michał Bentkowski" <[EMAIL PROTECTED]> wrote: > Why does python create a reference here, not just copy the variable? > > >>> j=range(0,6) > >>> k=j > >>> del j[0] > >>> j > [1, 2, 3, 4, 5] > >>> k > > [1, 2, 3, 4, 5] > > Shouldn't k remain the same? http://www.effbot.org/zone/

Re: Why does python behave so? (removing list items)

2008-03-26 Thread Thomas Dybdahl Ahle
On Wed, 2008-03-26 at 23:04 +0100, Michał Bentkowski wrote: > Why does python create a reference here, not just copy the variable? Python, like most other oo languages, will always make references for =, unless you work on native types (numbers and strings). Instead use one of: k = j[:] or k = [

Why does python behave so? (removing list items)

2008-03-26 Thread Michał Bentkowski
Why does python create a reference here, not just copy the variable? >>> j=range(0,6) >>> k=j >>> del j[0] >>> j [1, 2, 3, 4, 5] >>> k [1, 2, 3, 4, 5] Shouldn't k remain the same? -- Michał Bentkowski [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list