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).
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,
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
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
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
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
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,
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/
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 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
10 matches
Mail list logo