Re: [Tutor] Parsing suggestion? (CUE file) -- identify result

2009-02-04 Thread spir
Le Tue, 3 Feb 2009 17:36:41 -0500, Kent Johnson a écrit : > I think your use of the csv module is fine. What I really meant to say > was more like, I would have looked to pyparsing to solve the same > problem, and if you want a parser that parses the file into meaningful > records, then it might

[Tutor] VPython and Tkinter

2009-02-04 Thread Mr Gerard Kelly
Is there a way to make separate VPython and Tkinter windows run simultaneously from the one program? Or to have the VPython window run inside a Tkinter toplevel? If I have a program that uses both, it seems that one window has to close before the other will start running. _

Re: [Tutor] Sort of database & "family tree" question

2009-02-04 Thread spir
Le Wed, 4 Feb 2009 01:16:17 + (GMT), ALAN GAULD a écrit : > > > And I assume you are reading these into a Person class and > > > storing these classes in a persons dictionary? > > > > Can you explain this a little more for me please? > > > Sure. > (I didn't notice this on gmane so apolo

Re: [Tutor] Sort of database & "family tree" question

2009-02-04 Thread Alan Gauld
"spir" wrote > The current way of reading the data is this: > > def get_info(person) >infoDic = {} >infoDic['first'] = parser.get(person, 'firstName') >infoDic['last'] = parser.get(person, 'lastName') >infoDic['father'] = parser.get(person, 'father') >infoDic[

[Tutor] inheriting different builtin types

2009-02-04 Thread spir
Hello, I have a strange problem and cannot see a clear method to solve it. I would like to build a custom type that is able to add some informational attributes and a bunch attribute to a main "value". The outline is then: class Custom(X): def __init__(self, value, more):

[Tutor] reading file, adding to each line, writing file

2009-02-04 Thread David
Hello everybody, I have easily spent some four hours on this problem, and I am now asking for rescue. Here is what I am trying to do: I have a file ("step2", with some 30 or so lines. To each line I would like to add " -d" at the end. Finally, I want to save the file under another name ("pyo

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread A.T.Hofkamp
David wrote: line = infile.readline()# Invokes readline() method on file while line: outfile.write(line),# trailing ',' omits newline character line = infile.readline() The 'while' loop can be replaced by a 'for' loop, like for line in infile: outfile.write(line) infile.cl

Re: [Tutor] [Visualpython-users] VPython and Tkinter

2009-02-04 Thread Bruce Sherwood
In Visual 3, there is an example program (Tk-visual.py, if I remember correctly) which shows a Tk window controlling actions in a separate Visual window. In Visual 5, I believe that this program would still work on Windows and Linux, but because there seems to be no way to make this work in t

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread David
Hello Albert, thanks for your answer! A.T.Hofkamp wrote: The 'while' loop can be replaced by a 'for' loop, like for line in infile: outfile.write(line) I first was thinking of/experimenting with a 'for' loop, but what I originally had in mind was to combine the 'for' loop with readline()

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread Andre Engels
On Wed, Feb 4, 2009 at 3:30 PM, David wrote: > Hello everybody, > > I have easily spent some four hours on this problem, and I am now asking for > rescue. > > Here is what I am trying to do: I have a file ("step2", with some 30 or so > lines. To each line I would like to add " -d" at the end. Fina

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread OkaMthembo
The following is adapted from my humble text processing script that i use at work for a recurring task of mine. Any excuse not to use Java all day :) file_1 = open('step2', 'r+') lines = file_1.readlines() sentences = [] for line in lines: if line: sentences.i

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread OkaMthembo
The following is adapted from my humble text processing script that i use at work for a recurring task of mine. Any excuse not to use Java all day :) There was an error with my other posts. Pardon the triple posting - won't happen again soon. file_1 = open('step2', 'r+') lines = file_1.

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread Kent Johnson
On Wed, Feb 4, 2009 at 10:18 AM, OkaMthembo wrote: > The following is adapted from my humble text processing script that i use at > work for a recurring task of mine. Any excuse not to use Java all day :) > > There was an error with my other posts. Pardon the triple posting - won't > happen again

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread David
Hello Arthur, not there yet A.T.Hofkamp wrote: The simplest solution would be to construct a new line from the old one directly below the 'while', for example line2 = line[:-1] + " -d\n" followed by writing line2 to disk. Actually, I don't quite understand. You want me to put line2 =

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread OkaMthembo
Hmm...thanks Kent. Could use such information myself. I did feel that my code was bloated or could be tweaked somehow. Ha...there i double posted again :( Am having trouble paying attention today. On Wed, Feb 4, 2009 at 5:42 PM, Kent Johnson wrote: > On Wed, Feb 4, 2009 at 10:18 AM, OkaMthembo

Re: [Tutor] Sort of database & "family tree" question

2009-02-04 Thread Timo
Alan Gauld schreef: "spir" wrote > The current way of reading the data is this: > > def get_info(person) >infoDic = {} >infoDic['first'] = parser.get(person, 'firstName') >infoDic['last'] = parser.get(person, 'lastName') >infoDic['father'] = parser.get(person, 'fat

[Tutor] re division problem

2009-02-04 Thread prasad rao
hi I modified my function ' vertical' by adding a few characters to eliminate the division problem. def vertical(columns): if columns>7: columns=7 import string v=string.printable v=v.replace('\n','') v=v.replace('\t','') if len(v)%columns !=0:

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
eShopping wrote: Bob I am trying to read UNFORMATTED files. The files also occur as formatted files and the format string I provided is the string used to write the formatted version. I can read the formatted version OK. I (naively) assumed that the same format string was used for both fil

[Tutor] Eliminating options

2009-02-04 Thread Dinesh B Vadhia
Hi! I'm using 32-bit Python on Windows 64-bit Vista (instead of 64-bit Python because I also use Numpy/Scipy which doesn't offer 64-bit versions yet). I'm doing some very simple text processing ie. given a string s, find a subtring using s.find(). But, the program doesn't find all instances o

Re: [Tutor] reading binary files

2009-02-04 Thread eShopping
Bob sorry, I misread your email and thought it said "read on" if the file was FORMATTED. It wasn't so I didn't (but should have). I read the complete thread and it is getting a little messy so I have extracted your questions and added some answers. I'd like to examine the file myself. We

Re: [Tutor] reading binary files

2009-02-04 Thread Alan Gauld
"eShopping" wrote I now understand why Python gave me the results it did ... it looks like reading the FORTRAN file will be a non-trivial task so probably best to wait until I can post a copy of it. You don't say which OS you are on but you can read the binary file into a hex editor and see

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread Alan Gauld
"David" wrote Here is my latest try, which works: # add " -d" to each line of a textfile infile = open("step3", 'r') outfile = open("pyout","a") line = infile.readline()# Invokes readline() method on file line is now a string representing a line in the file. for i in line: You a

Re: [Tutor] reading binary files

2009-02-04 Thread bob gailer
eShopping wrote: The file is around 800 Mb but I can't get hold of it until next week so suggest starting a new topic once I have a cut-down copy. OK will wait with bated breath. Well, did you read on? What reactions do you have? I did (finally) read on and I am still a little confused, t

Re: [Tutor] Sort of database & "family tree" question

2009-02-04 Thread Alan Gauld
"Timo" wrote class Person: def __init__(self, parser): self.first = parser.get(person, 'firstName') Hey Alan, thanks for that explanation! But the class you gave, does almost the same thing as my function. That was my point. Its just a prettier way of handling it and slight

[Tutor] tkinter and visual with objects

2009-02-04 Thread Mr Gerard Kelly
I'm trying to make this very simple program, where the idea is that you click a tkinter button named "Ball" and then a ball will appear in the visual window. Problem is that the window itself doesn't pop up until the button is pressed and the ball is created. I would like it to start out blank, an

Re: [Tutor] reading file, adding to each line, writing file

2009-02-04 Thread tiefeng wu
> Hello everybody, > > I have easily spent some four hours on this problem, and I am now asking > for rescue. > > Here is what I am trying to do: I have a file ("step2", with some 30 or > so lines. To each line I would like to add " -d" at the end. Finally, I > want to save the file under another n