Leif K-Brooks wrote:
> Duncan Booth wrote:
>> The constant integers are created in advance, not when you do the
>> assignment.
>
> But that's just an optimization, not Python's defined behavior. It seems
> more useful to me to think of all integers as being created at
> assignment time, even if
Duncan Booth wrote:
> The constant integers are created in advance, not when you do the
> assignment.
But that's just an optimization, not Python's defined behavior. It seems
more useful to me to think of all integers as being created at
assignment time, even if CPython doesn't actually do that.
Shane Hathaway 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 and when does it
>> mean make a copy of the object??
>
> To understand this in C++ terms, you have to
this might help..
http://effbot.org/zone/python-objects.htm
--
http://mail.python.org/mailman/listinfo/python-list
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 and when does it mean make
> a copy of the object??
To understand this in C++ terms, you have to treat everything, including
simple inte
> "Dave Brueck" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
>>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 mea
On 2005-05-31, Michael <[EMAIL PROTECTED]> wrote:
> except numbers??
Um, no?
Unless you provide some context, how are we supposed to know
what you're asking about?
Numbers are immutable, so there is no practical difference.
--
Grant Edwards grante Yow! Are we T
Nope, numbers too. When you do:
a = 4
You are storing a reference to the literal 4 in a.
>>> a = 4>>> dir(a)['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getne
wa
Michael wrote:
> if i do
> a=2
> b=a
> b=0
> then a is still 2!?
>
> so when do = mean a reference to the same object and when does it mean make
> a copy of the object??
It *always* means a reference. It *never* makes a copy.
Although the terminology isn't quite right, you can think of all
"var
Michael wrote:
> a=2
> b=a
> b=0
That's more or less equivalent to this C++ code:
int *a;
int *b;
a = new int;
*a = 2;
b = a;
b = new int;
*b = 0;
--
http://mail.python.org/mailman/listinfo/python-list
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.
>
T
except numbers??
"Dave Brueck" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
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.
-Dave
--
http://mail.python.org/mailman/listinfo/python-list
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Michael wrote:
> > Do expicit pointers exist in python??
> >
> > if i do:
> >
> > a = [5,7]
> > b = a
> >
> > a.empty()
> >
> > b = ?
>
> This is what the interactive prompt is for. Try it:
>
> py> a = [5,7]
> py> b = a
Michael wrote:
> Do expicit pointers exist in python??
>
> if i do:
>
> a = [5,7]
> b = a
>
> a.empty()
>
> b = ?
This is what the interactive prompt is for. Try it:
py> a = [5,7]
py> b = a
py> a.empty()
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'list' objec
Do expicit pointers exist in python??
if i do:
a = [5,7]
b = a
a.empty()
b = ?
how do i do explicit pointers??
Mike
--
http://mail.python.org/mailman/listinfo/python-list
16 matches
Mail list logo