Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eike Welk
I have written the exact same reply. Sorry for that! I should have read the other replies first. Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eike Welk
On Sunday 07 October 2007 21:29, Happy Deer wrote: > Thank all for the discussion. > Maybe I can separate my question into two. > > First, I have experience in Matlab, where I can use "eval". I > wonder whether someone knows about it. I suspect you are using Numpy, you should subscribe to the Nump

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Happy Deer wrote: > I am writing a function getdata for other people, and I want others can > use the function as follows. > > var1,var2, var3=getdata(..., ['var1','var2','var3'],...) There is no need to pass the variable names to getdata. Have you read any Python tutorials? There are several g

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eric Brunson
Happy Deer wrote: > I am writing a function getdata for other people, and I want others > can use the function as follows. > > var1,var2, var3=getdata(..., ['var1','var2','var3'],...) > > If I can not return data column by column, I can not get the above, > right? Given: data = [ 1, 2, 3, 4, 5,

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Happy Deer wrote: > First, I have experience in Matlab, where I can use "eval". I wonder > whether someone knows about it. Python has an eval() function but it's use is discouraged, there is usually a better way. It would help if you would give us more context for your problem. > Second, if I

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Happy Deer
I am writing a function getdata for other people, and I want others can use the function as follows. var1,var2, var3=getdata(..., ['var1','var2','var3'],...) If I can not return data column by column, I can not get the above, right? On 10/7/07, Eric Brunson <[EMAIL PROTECTED]> wrote: > > Happy D

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eric Brunson
Happy Deer wrote: > Thank all for the discussion. > Maybe I can separate my question into two. > > First, I have experience in Matlab, where I can use "eval". I wonder > whether someone knows about it. > > Second, if I just want to return data[:,1], ...data[:,-1] separately > without knowing ahea

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Happy Deer
Thank all for the discussion. Maybe I can separate my question into two. First, I have experience in Matlab, where I can use "eval". I wonder whether someone knows about it. Second, if I just want to return data[:,1], ...data[:,-1] separately without knowing ahead how many columns data has. What

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Kent Johnson wrote: > Alan Gauld wrote: >> "Kent Johnson" <[EMAIL PROTECTED]> wrote >> The notation data[;,0] doesn't make sense and is an error in Python. >>> [:,0] is an extended slice, not an error: >>> http://docs.python.org/ref/slicings.html We discussed this quite a bit last July:

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Alan Gauld wrote: > "Kent Johnson" <[EMAIL PROTECTED]> wrote > >>> The notation data[;,0] doesn't make sense and is an error in >>> Python. >> [:,0] is an extended slice, not an error: >> http://docs.python.org/ref/slicings.html >> > > Really? I got an error from the interpreter. > d[:,0]

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >> The notation data[;,0] doesn't make sense and is an error in >> Python. > > [:,0] is an extended slice, not an error: > http://docs.python.org/ref/slicings.html > Really? I got an error from the interpreter. >>> d[:,0] Traceback (most recent call last

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Happy Deer wrote: > Dear all- > > I am writing a function as follows. > > def getdata(varlist): > > > eventually I have a variable called "data", which have exactly the same > number of columns as the name of variables in varlist. > Say varlist=['var1','var2','var3']. I want to assign var

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Kent Johnson
Alan Gauld wrote: > The notation data[;,0] doesn't make sense and is an error in Python. > I#m not sure what you think it does. I assume you simply mean > data[0]? [:,0] is an extended slice, not an error: http://docs.python.org/ref/slicings.html It is used in Numeric/numpy to select from multidi

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Alan Gauld
"Happy Deer" <[EMAIL PROTECTED]> wrote > def getdata(varlist): > > > eventually I have a variable called "data", which have exactly the > same > number of columns as the name of variables in varlist. > Say varlist=['var1','var2','var3']. I want to assign > var1=data[:,0], > var2=data[:,1]

[Tutor] a code question, but don't know question's name

2007-10-06 Thread Happy Deer
Dear all- I am writing a function as follows. def getdata(varlist): eventually I have a variable called "data", which have exactly the same number of columns as the name of variables in varlist. Say varlist=['var1','var2','var3']. I want to assign var1=data[:,0], var2=data[:,1], var3=data[