Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Alan Gauld
On 22/02/12 05:44, Elaina Ann Hyde wrote: file is enormous, has over 50,000 rows and about 20 columns. On modern computers its not that enormous - probably around 10M? But there are techniques for this which we can cover another time is you do hit files bigger than fit in memory. I didn't g

Re: [Tutor] Pyhton editor

2012-02-22 Thread Alan Gauld
On 22/02/12 04:00, ken brockman wrote: Being a neophyte to Python, I was under the impression that you had to install tkinter independently.of python. No, its part of the standard library. On some *nix installs tk support is not compiled in but tkinter should be there. But on Windows its alwa

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Walter Prins
Hi Elaina, On 22 February 2012 05:44, Elaina Ann Hyde wrote: > #select the value if it is very, very, very close >     if i != j and Radeg[i] <= (Radeg2[j]+0.01) and Radeg[i] Alan's pretty much said what I was thinking, but I have an additional question/concern: Why do you inclu

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Steven D'Aprano
On Wed, Feb 22, 2012 at 04:44:57PM +1100, Elaina Ann Hyde wrote: > So, Python question of the day: I have 2 files that I could normally just > read in with asciitable, The first file is a 12 column 8000 row table that > I have read in via asciitable and manipulated. The second file is > enormous,

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Peter Otten
Elaina Ann Hyde wrote: > So, Python question of the day: I have 2 files that I could normally just > read in with asciitable, The first file is a 12 column 8000 row table that > I have read in via asciitable and manipulated. The second file is > enormous, has over 50,000 rows and about 20 column

[Tutor] return integer from function

2012-02-22 Thread David Craig
Hi, I have a function that calculates the distance between two points on a sphere. It works but I cant get it to return a float for use in another script. Anyone know how I do that?? The function is below, Thanks, D import math def distance_on_unit_sphere(lat1, long1, lat2, long2): # Con

Re: [Tutor] return integer from function

2012-02-22 Thread Brian van den Broek
On 22 February 2012 12:57, David Craig wrote: > Hi, > I have a function that calculates the distance between two points on a > sphere. It works but I cant get it to return a float for use in another > script. Anyone know how I do that?? > >    cos = (math.sin(phi1)*math.sin(phi2)*math.cos(theta

[Tutor] Create a table by writing to a text file.

2012-02-22 Thread David Craig
Hi, I have created a list of containing strings that represent distances between many different points and would like to display the results in a table. I have been trying to write them to a text file but it is difficult to organise them into rows and columns with appropriate spacing to make it

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Evert Rol
> Hi, > I have created a list of containing strings that represent distances between > many different points and would like to display the results in a table. > I have been trying to write them to a text file but it is difficult to > organise them into rows and columns with appropriate spacing to

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Mark Lawrence
On 22/02/2012 13:40, Evert Rol wrote: Hi, This is always a tricky thing to go about. Nicely human-readable doesn't imply nicely machine readable. Sometimes a single space or a single tab between values/columns is more practical for a(nother) program to read, but not for humans. So I will work

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Steven D'Aprano
David Craig wrote: I have been trying to write them to a text file but it is difficult to organise them into rows and columns with appropriate spacing to make it readable. I would like something like, Stations Station1 Station2 Station1 0.033.57654 Station2 33

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Peter Otten
David Craig wrote: > distance = [[]]*len(stations) That doesn't do what you think it does: >>> a = [[]] * 3 >>> a [[], [], []] >>> a[0].append(42) >>> a [[42], [42], [42]] See? You get a list that contains the same list len(stations) times. Use [[] for _ in stations] instead. __

Re: [Tutor] return integer from function

2012-02-22 Thread Steven D'Aprano
David Craig wrote: Hi, I have a function that calculates the distance between two points on a sphere. It works but I cant get it to return a float for use in another script. Anyone know how I do that?? You are going to have to explain what you mean in more detail. If you mean, how can you pa

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread David Craig
Thanks everyone, was able to get what I wanted from '/t' but I'm sure the other formatting options will be useful in future. @Peter a = [[]] * 3 >>> a [[], [], []] >>> a[0].append(42) >>> a [[42], [42], [42]] you had me worried for a minute, but a = [[]] * 3 a[0]=[1,2,3] a [[1, 2, 3], [

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Jerry Hill
On Wed, Feb 22, 2012 at 10:24 AM, David Craig wrote: > you had me worried for a minute, but > a = [[]] * 3 > a[0]=[1,2,3] > a > [[1, 2, 3], [], []] > That's not the same thing. In your example you create three copies of the same empty list inside your outer list. You then throw away the first

Re: [Tutor] how to rewrite area.py

2012-02-22 Thread William Stewart
On 2/21/2012 6:51 PM, William Stewart wrote: hello I need to rewrite area.py program so that it has separate functions for the perimeter and area of a square, a rectangle, and a circle (3.14 * radius**2). "Need to"" - why? Is this a homework assignment? I am horrible at ma

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Alan Gauld
On 22/02/12 13:14, David Craig wrote: Hi, I have created a list of containing strings that represent distances between many different points and would like to display the results in a table. Others have mentioned using format strings. If it is only for display you could switch to html. Then de

[Tutor] Help Designing a simple Program called Life

2012-02-22 Thread leo degon
Hello All, My name is Leo. I'm just beginning to learn python. I am learning on my own and have no previous programming experience. I decided to create a version of john conway's game of life as a personal project. I've been wondering what GUI to use. I've been using Tkinter so far bu

Re: [Tutor] Help Designing a simple Program called Life

2012-02-22 Thread bob gailer
On 2/22/2012 1:50 PM, leo degon wrote: Hello All, My name is Leo. Hi Leo & Welcome to Python help. We are a few volunteers who like assisting others. A few guidelines: - always reply-all so a copy goes to the list - reply in-line rather than at the top. - if your code is large put

Re: [Tutor] Recognizing real numbers

2012-02-22 Thread bob gailer
On 2/21/2012 10:00 PM, Michael Lewis wrote: Hi everyone, I have some code where I import a file to use a module. That module that I import takes text and a multiplier, checks for any numbers in that text and will then multiply those numbers by the given multiplier. The imported module is belo

[Tutor] I cannot "run" any Python programs

2012-02-22 Thread Tamar Osher
Hi. I need help. I have installed Python 3.2.2 and have been using IDLE (the "Python shell") to type and save a Python program, such as 'Hello World'. However, the command prompt (the black box) will not allow me to type a Python program or to "run" a Python program. So I tried to run a Pyth

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Joel Goldstick
On Wed, Feb 22, 2012 at 5:23 PM, Tamar Osher wrote: > Hi.  I need help. > > I have installed Python 3.2.2 and have been using IDLE (the "Python shell") > to type and save a Python program, such as 'Hello World'. > > However, the command prompt (the black box) will not allow me to type a > Python p

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Tamar Osher
Dear Joel: HI! Thanks for helping. When I use the Python shell, and navigate to the saved Python program, what happens is: A second Python shell pops up, displaying the coding of the program (which is a tiny 'hello world' program). This is what is displayed in the second Python shell: >>> pr

Re: [Tutor] Recognizing real numbers

2012-02-22 Thread Dave Angel
On 02/21/2012 10:00 PM, Michael Lewis wrote: Hi everyone, I have some code where I import a file to use a module. That module that I import takes text and a multiplier, checks for any numbers in that text and will then multiply those numbers by the given multiplier. The imported module is below.

Re: [Tutor] Recognizing real numbers

2012-02-22 Thread Joel Goldstick
On Wed, Feb 22, 2012 at 4:35 PM, bob gailer wrote: > On 2/21/2012 10:00 PM, Michael Lewis wrote: > > Hi everyone, > > I have some code where I import a file to use a module. That module that I > import > > takes text and a multiplier, checks for any numbers in that text and will > then multiply th

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Joel Goldstick
On Wed, Feb 22, 2012 at 5:49 PM, Tamar Osher wrote: > Dear Joel: HI!  Thanks for helping.  When I use the Python shell, and > navigate to the saved Python program, what happens is: > A second Python shell pops up, displaying the coding of the program (which > is a tiny 'hello world' program).  Thi

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Tamar Osher
Dear Joel: Hi! Thanks for helping. I typed cmd, and got the same black box, this time labeled C:\windows\system32\cmd.exe instead of "Command Prompt". When I type python myprogram.py, this is what appears on the screen:'python' is not recognized as an internal or external command, operable p

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Joel Goldstick
On Wed, Feb 22, 2012 at 6:11 PM, Tamar Osher wrote: > Dear Joel: Hi!  Thanks for helping.  I typed cmd, and got the same black > box, this time labeled C:\windows\system32\cmd.exe instead of "Command > Prompt".  When I type python myprogram.py, this is what appears on the > screen: > 'python' is n

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Tamar Osher
Thanks! I hope to find a Windows7 expert to help me. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to rewrite area.py

2012-02-22 Thread William Stewart
so I copied your format except I changed shape 3 to circle, Did I do the circle part right? and would this be considered seperate functions?   Thanks for your help import math from math import pi menu = """ Pick a shape(1-3):    1) Square    2) Rectangle    3) Triangle    4) Quit """ shape = int

Re: [Tutor] Help Designing a simple Program called Life

2012-02-22 Thread Alan Gauld
On 22/02/12 18:50, leo degon wrote: Hello All, My name is Leo. I'm just beginning to learn python. I am learning on my own and have no previous programming experience. I decided to create a version of john conway's game of life as a personal project. OK, Thats quite a good project

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Mark Lawrence
On 22/02/2012 23:29, Tamar Osher wrote: Thanks! I hope to find a Windows7 expert to help me. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Try reading this http:

Re: [Tutor] I cannot "run" any Python programs

2012-02-22 Thread Alan Gauld
On 22/02/12 23:29, Tamar Osher wrote: Thanks! I hope to find a Windows7 expert to help me. You don't need a Windows 7 expert, just to set things up properly. First open up Notepad++ again and enter everything between the then save to a file called myHello.py and exit Notepad++. #

Re: [Tutor] how to rewrite area.py

2012-02-22 Thread Alan Gauld
On 22/02/12 23:45, William Stewart wrote: so I copied your format except I changed shape 3 to circle, Did I do the circle part right? Nearly. The circumference is wrong, you need to calculate it not read it from the user. and would this be considered separate functions? No, but your seco

[Tutor] help writing functions

2012-02-22 Thread Saad Javed
I am learning python and need guidance for writing some code. I've written a simple program (with pointers from people) that parses an tv show xml feed and prints their values in plain text after performing some string operations. [CODE]feed = urllib.urlopen(rssPage) #rssPage: address of xml feed

[Tutor] Which computer operating system is best for Python developers?

2012-02-22 Thread Tamar Osher
Hi. I am still having trouble installing and using Python on my (new) Windows 7 computer, but I plan to contact Microsoft forums and see if they can help me, since this is a Windows problem and not a Python problem. My question: For the future, what type of computer is best for Python develop

Re: [Tutor] Which computer operating system is best for Python developers?

2012-02-22 Thread David Rock
* Tamar Osher [2012-02-22 19:00]: > > Hi. I am still having trouble installing and using Python on my (new) > Windows 7 computer, but I plan to contact Microsoft forums and see if > they can help me, since this is a Windows problem and not a Python > problem. > > My question: For the future, wh

Re: [Tutor] Which computer operating system is best for Python developers?

2012-02-22 Thread Mark Lawrence
On 23/02/2012 01:00, Tamar Osher wrote: Hi. I am still having trouble installing and using Python on my (new) Windows 7 computer, but I plan to contact Microsoft forums and see if they can help me, since this is a Windows problem and not a Python problem. My question: For the future, what ty

[Tutor] installing Python and running a Python program

2012-02-22 Thread Tamar Osher
Dear Alan: Hi. Thanks for helping me. I did it exactly the way you described, and everything worked perfectly. Thanks for being a kind friend! >From Your Friend: Tamar Osher Email: emeraldoff...@hotmail.com __

Re: [Tutor] Recognizing real numbers (bob gailer)

2012-02-22 Thread Michael Lewis
> Hi everyone, > > I have some code where I import a file to use a module. That module > that I import > takes text and a multiplier, checks for any numbers in that text and > will then multiply those numbers by the given multiplier. The imported > module is below. I am getting the text from a fil

Re: [Tutor] Recognizing real numbers

2012-02-22 Thread Michael Lewis
On Wed, Feb 22, 2012 at 2:52 PM, Dave Angel wrote: > On 02/21/2012 10:00 PM, Michael Lewis wrote: > >> Hi everyone, >> >> I have some code where I import a file to use a module. That module that I >> import takes text and a multiplier, checks for any numbers in that text >> and >> will then multi

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Elaina Ann Hyde
On Wed, Feb 22, 2012 at 8:50 PM, Peter Otten <__pete...@web.de> wrote: > Elaina Ann Hyde wrote: > > > So, Python question of the day: I have 2 files that I could normally > just > > read in with asciitable, The first file is a 12 column 8000 row table > that > > I have read in via asciitable and

Re: [Tutor] Recognizing real numbers

2012-02-22 Thread Dave Angel
On 02/22/2012 08:54 PM, Michael Lewis wrote: On Wed, Feb 22, 2012 at 2:52 PM, Dave Angel wrote: I actually have a function written in my imported file to check if a string is a valid float, but I didn't use it because I also have raw_input in that same function, which I don't want. I'll rework

Re: [Tutor] Reading/dealing/matching with truly huge (ascii) files

2012-02-22 Thread Mark Lawrence
On 23/02/2012 01:55, Elaina Ann Hyde wrote: [big snips] Hi Elaina, I'm sorry but I can't help with your problem with the memory cos I don't know enough about the combination of Python and Unix wrt memory management. However can I suggest that you use more whitespace in your code to make it

[Tutor] Compiled Python File

2012-02-22 Thread Michael Lewis
First, thanks to everyone who helped me out regarding my Recognizing real numbers post. I gained a lot of knowledge over the past two days! I've noticed that after I execute some of my .py files, a Compiled Python File is automatically saved to my directory. This doesn't happen for every file that

Re: [Tutor] Compiled Python File

2012-02-22 Thread Steven D'Aprano
On Wed, Feb 22, 2012 at 07:29:42PM -0800, Michael Lewis wrote: > First, thanks to everyone who helped me out regarding my Recognizing real > numbers post. I gained a lot of knowledge over the past two days! > > I've noticed that after I execute some of my .py files, a Compiled Python > File is aut

Re: [Tutor] Which computer operating system is best for Python developers?

2012-02-22 Thread Steven D'Aprano
On Wed, Feb 22, 2012 at 07:00:57PM -0600, Tamar Osher wrote: > > Hi. I am still having trouble installing and using Python on my (new) > Windows 7 computer, but I plan to contact Microsoft forums and see if they > can help me, since this is a Windows problem and not a Python problem. > > My qu

[Tutor] Writing to a file/changing the file name

2012-02-22 Thread Michael Lewis
Hi everyone, I have a program where I open a file (recipe.txt), I read that file and write it to another file. I am doing some multiplying of numbers in between; however, my question is, when I name the file I am writing to, the file extension is changed, but the file name is not. What am I doing

Re: [Tutor] Writing to a file/changing the file name

2012-02-22 Thread Christian Witts
On 2012/02/23 07:04 AM, Michael Lewis wrote: Hi everyone, I have a program where I open a file (recipe.txt), I read that file and write it to another file. I am doing some multiplying of numbers in between; however, my question is, when I name the file I am writing to, the file extension is c

Re: [Tutor] help writing functions

2012-02-22 Thread Andreas Perstinger
On 2012-02-23 01:59, Saad Javed wrote: I am learning python and need guidance for writing some code. I've written a simple program (with pointers from people) that parses an tv show xml feed and prints their values in plain text after performing some string operations. [CODE]feed = urllib.urlope