Re: Preferred method for "Assignment by value"

2008-04-16 Thread castironpi
On Apr 15, 3:51 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > On Apr 15, 8:19 pm, [EMAIL PROTECTED] wrote: > > > Coming from VBA I have a tendency to think of everything as an > > array... > > Coding to much in Visual Basic, like Fortran 77, is bad for your mind. The distinction you're looking for

Re: Preferred method for "Assignment by value"

2008-04-15 Thread sturlamolden
On Apr 15, 8:19 pm, [EMAIL PROTECTED] wrote: > Coming from VBA I have a tendency to think of everything as an > array... Coding to much in Visual Basic, like Fortran 77, is bad for your mind. -- http://mail.python.org/mailman/listinfo/python-list

Re: Preferred method for "Assignment by value"

2008-04-15 Thread sturlamolden
On Apr 15, 7:23 pm, [EMAIL PROTECTED] wrote: > test = [[1],[2]] > x = test[0] Python names are pointer to values. Python behaves like Lisp - not like Visual Basic or C#. Here you make x point to the object which is currently pointed to by the first element in the list test. If you now reassign

Re: Preferred method for "Assignment by value"

2008-04-15 Thread Robin Stocker
[EMAIL PROTECTED] schrieb: > by changing temp = v[:] the code worked perfectly (although changing > temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't > like that as I knew it was a workaround) So the for body now looks like this?: temp = v[:] temp.insert(0, k) finallist.

Re: Preferred method for "Assignment by value"

2008-04-15 Thread duncan smith
[EMAIL PROTECTED] wrote: > Thank you both, the assigning using slicing works perfectly (as I'm > sure you knew it would)... It just didn't occur to me because it > seemed a little nonintuitive... The specific application was > > def dicttolist (inputdict): > finallist=[] > for k, v in inpu

Re: Preferred method for "Assignment by value"

2008-04-15 Thread hall . jeff
I think the fundamental "disconnect" is this issue of mutability and immutability that people talk about (mainly regarding tuples and whether they should be thought of as static lists or not) Coming from VBA I have a tendency to think of everything as an array... So when I create the following t

Re: Preferred method for "Assignment by value"

2008-04-15 Thread Michael Tobis
http://effbot.org/zone/python-objects.htm still says it best. mt -- http://mail.python.org/mailman/listinfo/python-list

Re: Preferred method for "Assignment by value"

2008-04-15 Thread hall . jeff
Thank you both, the assigning using slicing works perfectly (as I'm sure you knew it would)... It just didn't occur to me because it seemed a little nonintuitive... The specific application was def dicttolist (inputdict): finallist=[] for k, v in inputdict.iteritems(): temp = v

Re: Preferred method for "Assignment by value"

2008-04-15 Thread Arnaud Delobelle
On Apr 15, 6:23 pm, [EMAIL PROTECTED] wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's t

Re: Preferred method for "Assignment by value"

2008-04-15 Thread Matimus
On Apr 15, 10:23 am, [EMAIL PROTECTED] wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's

Re: Preferred method for "Assignment by value"

2008-04-15 Thread Gary Herron
[EMAIL PROTECTED] wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm u

Preferred method for "Assignment by value"

2008-04-15 Thread hall . jeff
As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than by value (I'm coming from a VBA world so that's the terminology I'm using). I was surprised that these