Hi Everyone,
I would like to create a two-dimensional array but am confused as to
how to go about it.
I've read about Numeric Python and Numpy. Are they one and the same?
Also, how do I install them? I am working on a Windows machine.
I've been getting the following error messages:
import
No, they are not the same. Numeric is older; NumArray is another older
package. You should use Numpy if you can.
http://numpy.scipy.org/#older_array
snip
Now you should be able to import numpy.
Kent
Thanks, Kent. I ended up using:
from numpy import *
I wasn't sure what the difference
In general from module import * is a very bad idea.
import module imports a module into its own namespace (e.g., to
access its functionality you would have to do module.foo() and
module.bar() The form that you chose to use imports all of a
module's contents into the current namespace. This
A useful tip is that if you have a long module name you can also use
import module as shortname
eg
import numpy as n
and then access numpy.foo() as
n.foo()
Sacves a lot of typing for a slight loss of clarity in
maintenance - you have to remember which module the
short names refer
Another reason not to use from xx import * is that it can make it
very difficult to discover where a name is defined. If you have
several from xx import * lines and then later you use a function
foo() there is no easy way to tell which module foo came from.
An alternative is to list just the
Hi Everyone,
I am trying to read a comma-delimitted list (aaa,bbb,ccc) from a text
file and assign those values to a list, x, such that:
x = [aaa, bbb, ccc]
The code that I have come up with looks like this:
x = []
f = open(r'c:\test.txt', 'r')
x.extend(f.readlines())
x
['aaa,bbb,ccc']
If
Hi Everyone,
Thanks for the variety of responses in such a short amount of time.
This distribution list is incredible.
Sorry for the delayed reply as I wanted to test what everyone
suggested, so here goes:
---
@Amin: I tried your suggestion, but perhaps I don't
=
csv.Reader(myfile, delimeter = ',')
should be data = csv.reader(myfile, delimeter = ',')
2008/7/31 S Python [EMAIL PROTECTED]
Hi Everyone,
Thanks for the variety of responses in such a short amount of time.
This distribution list is incredible.
Sorry for the delayed reply as I wanted
Date: Thu, 31 Jul 2008 11:34:56 -0700
Subject: Re: [Tutor] Reading List from File
S Python wrote:
f = open(r'C:\test.txt', 'r')
foo = f.readline.split(',')
readline is the function/method name
readline() executes that function/method and returns a value
try typing in 'type(f.readline
Hi Morgan,
Have you installed Python on your computer? If you are using Microsoft
Windows, you can download and install Python from here:
http://python.org/download/releases/2.5.2/
and select python-2.5.2.msi.
Once it's installed, you should have a directory on your machine called
C:\python25.
10 matches
Mail list logo