[Tutor] Confused about import Numeric vs import numpy for Arrays

2008-08-08 Thread S Python
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

Re: [Tutor] Confused about import Numeric vs import numpy for Arrays

2008-08-08 Thread S Python
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

Re: [Tutor] Confused about import Numeric vs import numpy for Arrays

2008-08-08 Thread S Python
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

Re: [Tutor] Confused about import Numeric vs import numpy forArrays

2008-08-08 Thread S Python
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

Re: [Tutor] Confused about import Numeric vs import numpy for Arrays

2008-08-08 Thread S Python
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

[Tutor] Reading List from File

2008-07-31 Thread S Python
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

Re: [Tutor] Reading List from File

2008-07-31 Thread S Python
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

Re: [Tutor] Reading List from File

2008-07-31 Thread S Python
= 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

Re: [Tutor] Reading List from File

2008-07-31 Thread S Python
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

Re: [Tutor] (no subject)

2008-07-29 Thread S Python
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.