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
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
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
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,
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
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
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
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
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:
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]
"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
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
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
"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]
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[
15 matches
Mail list logo