[Tutor] New to Python
learnpythonvs at gmail.com
Sat May 19 00:45:48 CEST 2012
I am new to Python too. I find docs.python.org very helpful.
*Reading and Writing Files:*
*Comments - Coding Style*
Hope the above links are useful.
On Thu, May 17, 2012 at 11:45 PM, Jeremy Traurig
<jeremy.traurig at gmail.com>wrote:
> I very new to python and have been playing around with some simple code
> that I would eventually use in the real word. Below is the code I have
> created. I want the code to read data from a file called SIL633.txt and
> then output that data into another file called test.txt. below is my code:
> #! /usr/bin/env python
> # Read NRG Text File
> def readNRGtxt():
> import numpy as np
> f1 = open('SIL633_original.txt','r')
> data = np.genfromtxt(f1,delimiter='\t',skip_header=141)
> f2 = open('test.txt','w')
> I'm running this on mac 10.5.8. When I run this script from the command
> line, there is no file output. However, if I remove the "def" statement in
> the script and run again from the command line, a test.txt file is output.
> I guess I'm trying to understand why using the def statement changes how
> the script operates and since it does, how do I correct this code so it
> runs from the command line with the def statement.
> thanks for any help -- jeremy
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor