Re: [Tutor] Tutor Digest, Vol 85, Issue 91

2011-03-24 Thread Lea Parker
Message 3 - I solved my problem. Yah Me!!! Thanks P.S I hope this is the right way to let you know so you don't waste your time. Lea -Original Message- From: tutor-bounces+lea-parker=bigpond@python.org [mailto:tutor-bounces+lea-parker=bigpond@python.org] On Behalf Of tutor-req

Re: [Tutor] Error in programming

2011-03-24 Thread bob gailer
On 3/25/2011 12:27 AM, Lea Parker wrote: *Hello* ** *Just wondering if you have some time to cast your eyes over another basic program.* Donald pointed out the first error. (actually there are 3 such spelling errors). When you get "name xxx is not defined" use your editor's find featu

Re: [Tutor] Error in programming

2011-03-24 Thread Donald Bedsole
Hi Lea, On Fri, Mar 25, 2011 at 1:27 AM, Lea Parker wrote: > Hello > > > > Just wondering if you have some time to cast your eyes over another  basic > program. > > > > # Prompt user for data > > def main(): > >     print 'This program is to calculate your ticket sales to the softball > game' > >

[Tutor] Error in programming

2011-03-24 Thread Lea Parker
Hello Just wondering if you have some time to cast your eyes over another basic program. # Prompt user for data def main(): print 'This program is to calculate your ticket sales to the softball game' print #blank line # Value of each lev

Re: [Tutor] Guessing Game Program

2011-03-24 Thread Donald Bedsole
On Fri, Mar 25, 2011 at 12:53 AM, Donald Bedsole wrote: > Hi Malcolm :-) > > On Fri, Mar 25, 2011 at 12:37 AM, Malcolm Newsome > wrote: >> Hey Don! >> >> I posted an eerily similar request to another python group about two weeks >> ago!  I, too, am very new to programming and the guessing game wa

Re: [Tutor] Guessing Game Program

2011-03-24 Thread Malcolm Newsome
Hey Don! I posted an eerily similar request to another python group about two weeks ago! I, too, am very new to programming and the guessing game was my first shot at writing a script from scratch! Below is my code (improved with some help from others). I still would like to make some improveme

[Tutor] Guessing Game Program

2011-03-24 Thread Donald Bedsole
Hi folks, This is a little program I've written to bring together some things I've been trying to learn (not an attempt, of course, to make an interesting game).. I've been working my way through a beginner's tutorial, and except for a very basic program I wrote in C++ one time, I think this is t

[Tutor] if os.path.exists() or if not os.path.exists()?

2011-03-24 Thread Susana Iraiis Delgado Rodriguez
OK!! I see the problem now! I also did a little change to the code, I open the .txt before the for stamentet. The script is working properly gdal.AllRegister() file_list = [ folders = Non for root, folders, files in os.walk( "C:\\" ): file_list.extend(os.path.join( root,fi) for fi in files if f

Re: [Tutor] Fw: Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread Joel Goldstick
On Thu, Mar 24, 2011 at 1:45 PM, wrote: > Sent from my BlackBerry® on the MetroPCS Network > -- > *From: * Louis LEICHTNAM > *Date: *Thu, 24 Mar 2011 11:51:26 -0400 > *To: * > *Subject: *Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC] > > > - Forwarded by Lo

Re: [Tutor] Fw: Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread Rafael Durán Castañeda
Look again the code from my last message: import urllib, csv url=r"http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv"; simpsons=urllib.urlopen(url) reader=csv.reader(simpsons, delimiter=',',quotechar='"') list_string = [] for char,meal,ate,qty,com in reader: if char != 'Cha

[Tutor] Fw: Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread l . leichtnam
Sent from my BlackBerry® on the MetroPCS Network -Original Message- From: Louis LEICHTNAM Date: Thu, 24 Mar 2011 11:51:26 To: Subject: Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC] - Forwarded by Louis LEICHTNAM/us/socgen on 03/24/2011 11:51 AM - Louis LEICHTNAM/us/so

[Tutor] Fw: Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread l . leichtnam
Sent from my BlackBerry® on the MetroPCS Network -Original Message- From: Louis LEICHTNAM Date: Thu, 24 Mar 2011 11:51:26 To: Subject: Fw: [Tutor] Fw: Fw: Parsing data from a csv file [NC] - Forwarded by Louis LEICHTNAM/us/socgen on 03/24/2011 11:51 AM - Louis LEICHTNAM/us/so

Re: [Tutor] if os.path.exists() or if not os.path.exists()?

2011-03-24 Thread Tom Zych
On Thu, 24 Mar 2011 09:22 -0600, "Susana Iraiis Delgado Rodriguez" wrote: > #This block is wrong, I think here is the problem > if os.path.exists(shx): > print 'El archivo ' +shx +' existe' > else: > log.write('No existe el archivo ' +shx + "\n") > i

Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread Rafael Durán Castañeda
Ok, I think what you are trying is to get all data in a string list: import urllib, csv url=r"http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv"; simpsons=urllib.urlopen(url) reader=csv.reader(simpsons,delimiter=',',quotechar='"') list_string = [] for char,meal,ate,qty,com in

[Tutor] if os.path.exists() or if not os.path.exists()?

2011-03-24 Thread Susana Iraiis Delgado Rodriguez
Hello everyone! I'm doing a python script that walks through files in my PC. Basically I'm searching files that end up with .shp, but these files must have extensions with .shx and .dbf. I want to write a .txt document which tells the user if a file doesn't exist in the directory. But I haven't be

Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread l . leichtnam
Thanks, what I'm trying to do is extract the data from the csv file, clean it to make each line into a sentence. But for this I think I need to use a dictionary for each and enter the words of each columns in one no? Sent from my BlackBerry® on the MetroPCS Network -Original Message- F

[Tutor] Pygame install error

2011-03-24 Thread Chuck
Hi, I'm trying to install pygame on my Win XP machine. I'm running Python 3.2. I can successfully use IDLE to run python scripts, and from the windows command line can run python from any directory. My PATH statement includes c:\python32;c:\python32\lib. pygame .msi file I used: pygame-1.9.1.win3

Re: [Tutor] Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread Rafael Durán Castañeda
I don't know what are you going to do with data, but you can save all data in either a list or a dictionary, for example: import urllib, csv url=r"http://www.cs.columbia.edu/~joshua/teaching/cs3101/simpsons_diet.csv"; simpsons=urllib.urlopen(url) reader=csv.reader(simpsons,delimiter=',',quotechar=

[Tutor] Fw: Fw: Parsing data from a csv file [NC]

2011-03-24 Thread l . leichtnam
Thank you for your help Sent from my BlackBerry® on the MetroPCS Network -Original Message- From: Louis LEICHTNAM Date: Thu, 24 Mar 2011 09:48:04 To: Subject: Re: Fw: [Tutor] Parsing data from a csv file [NC] Hello the loops are a bit different, and I definitely don't know if it's co

Re: [Tutor] Parsing data from a csv file

2011-03-24 Thread Joel Goldstick
On Thu, Mar 24, 2011 at 8:34 AM, louis leichtnam wrote: > Hello, > > I am to extract a csv file from the web and parse it in python and after > that make it into an html page. > > I want to get the data out of the csv file, get rid of the "," and make it > readable. > > Questions: > I would like t

[Tutor] Parsing data from a csv file

2011-03-24 Thread louis leichtnam
Hello, I am to extract a csv file from the web and parse it in python and after that make it into an html page. I want to get the data out of the csv file, get rid of the "," and make it readable. Questions: I would like to be able to print the line I want but I don't know how to do it. I would

Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Andre Engels
2011/3/24 Rafael Durán Castañeda : > I can do it with two list comprehensions: > list_ = [1, 2, [3, 4], 5, [6, 7, 8], 9] [x[i] for x in list_ if isinstance(x, list) for i in range(len(x))] + [x for x in list_ if not isinstance(x, list)] > [3, 4, 6, 7, 8, 1, 2, 5, 9] > > But i lo

Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Rafael Durán Castañeda
I can do it with two list comprehensions: >>> list_ = [1, 2, [3, 4], 5, [6, 7, 8], 9] >>> [x[i] for x in list_ if isinstance(x, list) for i in range(len(x))] + [x for x in list_ if not isinstance(x, list)] [3, 4, 6, 7, 8, 1, 2, 5, 9] >>> But i loose original order, Can anyone do it with just one

Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Tom Zych
Dharmit Shah wrote: > I am learning Python and yesterday I cam across a definition wherein I was > supposed to flatten a list recursively. I am getting the solution properly > but wanted to know if I can optimize the code further. > > #!/usr/bin/env python > new_list=[] > def flatten(num_list): >

Re: [Tutor] Recursively flatten the list

2011-03-24 Thread Peter Otten
Dharmit Shah wrote: > I am learning Python and yesterday I cam across a definition wherein I was > supposed to flatten a list recursively. I am getting the solution properly > but wanted to know if I can optimize the code further. > > #!/usr/bin/env python > new_list=[] > def flatten(num_list): >