Re: working with pointers

2005-06-01 Thread Duncan Booth
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

Re: working with pointers

2005-06-01 Thread Leif K-Brooks
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.

Re: working with pointers

2005-06-01 Thread Duncan Booth
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

Re: working with pointers

2005-06-01 Thread [EMAIL PROTECTED]
this might help.. http://effbot.org/zone/python-objects.htm -- http://mail.python.org/mailman/listinfo/python-list

Re: working with pointers

2005-05-31 Thread Shane Hathaway
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

Re: working with pointers

2005-05-31 Thread Rocco Moretti
> "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

Re: working with pointers

2005-05-31 Thread Grant Edwards
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

Re: working with pointers

2005-05-31 Thread Chris Cioffi
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

Re: working with pointers

2005-05-31 Thread Steven Bethard
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

Re: working with pointers

2005-05-31 Thread Leif K-Brooks
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

Re: working with pointers

2005-05-31 Thread Ivan Van Laningham
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

Re: working with pointers

2005-05-31 Thread Michael
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

Re: working with pointers

2005-05-31 Thread Dave Brueck
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

Re: working with pointers

2005-05-31 Thread Michael
"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

Re: working with pointers

2005-05-31 Thread Steven Bethard
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

working with pointers

2005-05-31 Thread Michael
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