Re: [Tutor] calling a variable name

2007-10-25 Thread Ricardo Aráoz
Kent Johnson wrote: > Dave Kuhlman wrote: >> On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote: >> >> [snip] >> >>> Perhaps I was a bit hasty. >>> >>> Lists are implemented as arrays of references. I believe they are >>> - amortized O(1) for append - occasionally the list must be realloc

Re: [Tutor] calling a variable name

2007-10-24 Thread Kent Johnson
Dave Kuhlman wrote: > On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote: > > [snip] > >> Perhaps I was a bit hasty. >> >> Lists are implemented as arrays of references. I believe they are >> - amortized O(1) for append - occasionally the list must be reallocated >> and copied > > OK.

Re: [Tutor] calling a variable name

2007-10-23 Thread Dave Kuhlman
On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote: [snip] > > Perhaps I was a bit hasty. > > Lists are implemented as arrays of references. I believe they are > - amortized O(1) for append - occasionally the list must be reallocated > and copied OK. I'm groping here. Wikipedia tel

Re: [Tutor] calling a variable name

2007-10-23 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> Use list when you want a sequence of items indexed by sequential integers. >> Lists >> - preserve order >> - are fast for indexed lookup >> - are relatively slow (O(n)) for adding, deleting and searching (though >> for small lists this should not be a

Re: [Tutor] calling a variable name

2007-10-23 Thread Ricardo Aráoz
Kent Johnson wrote: > Bryan Fodness wrote: >> Thank you. This works well. I am still trying to figure out the pros >> and cons of using an array, dictionary or list. > > Array is specialized, you probably want list or dict. > > Use list when you want a sequence of items indexed by sequential i

Re: [Tutor] calling a variable name

2007-10-22 Thread Kent Johnson
Bryan Fodness wrote: > Thank you. This works well. I am still trying to figure out the pros > and cons of using an array, dictionary or list. Array is specialized, you probably want list or dict. Use list when you want a sequence of items indexed by sequential integers. Lists - preserve order

Re: [Tutor] calling a variable name

2007-10-22 Thread Bryan Fodness
Thank you. This works well. I am still trying to figure out the pros and cons of using an array, dictionary or list. On 10/22/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Bryan Fodness wrote: > > Here is the actual snippet of code > > > > > > calc_depth =8.1 # which is actually d

Re: [Tutor] calling a variable name

2007-10-22 Thread Evert Rol
>> Here is the actual snippet of code >> >> >> calc_depth =8.1 # which is actually d >> unblockedFS = 13.4 # which is the indexed fs >> >> for line in file('21Ex6MV_tmr.dat'): >> d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11, fs12, >> fs13, fs14, fs15, fs16, fs17,

Re: [Tutor] calling a variable name

2007-10-22 Thread Kent Johnson
Bryan Fodness wrote: > Here is the actual snippet of code > > > calc_depth =8.1 # which is actually d > unblockedFS = 13.4 # which is the indexed fs > > for line in file('21Ex6MV_tmr.dat'): > d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11, fs12, > fs13, fs14,

Re: [Tutor] calling a variable name

2007-10-22 Thread Tino Dai
On 10/21/07, Bryan Fodness <[EMAIL PROTECTED]> wrote: > > > I want to get a variable name dependent on another variable. I have > tried, > > 'fs' + str(int(round(unblockedFS))) for fs13 > > and I get an invalid literal. If I code in the fs13, everything works. Is > it possible to do this? > > > >

Re: [Tutor] calling a variable name

2007-10-22 Thread Bryan Fodness
Here is the actual snippet of code calc_depth =8.1 # which is actually d unblockedFS = 13.4 # which is the indexed fs for line in file('21Ex6MV_tmr.dat'): d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10, fs11, fs12, fs13, fs14, fs15, fs16, fs17, fs18, fs19, fs20, fs21,

Re: [Tutor] calling a variable name

2007-10-22 Thread Alan Gauld
"Bryan Fodness" <[EMAIL PROTECTED]> wrote >I want to get a variable name dependent on another variable. Thats usually a bad idea, but... > I have tried, > > 'fs' + str(int(round(unblockedFS))) for fs13 I have no idea what you think this will do. It gives a syntax error for me, which is what I e

[Tutor] calling a variable name

2007-10-21 Thread Bryan Fodness
I want to get a variable name dependent on another variable. I have tried, 'fs' + str(int(round(unblockedFS))) for fs13 and I get an invalid literal. If I code in the fs13, everything works. Is it possible to do this? unblockedFS=13.4 for line in file('21Ex6MV_tmr.dat'): d, fs1, fs2, fs