[Tutor] Nested, line by line, file reading

2007-12-16 Thread jon vs. python
Hi everyone, I have a file with this content: "1 1 1 1 1 1 1 2 1 1" I wanted a little script that would print the line containing "2" and every line containing "1" after it. I've tried this: >>> def p(): f = file("prueba.txt",'r') for startline in f.read(): if startline.find("2")

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread bob gailer
jon vs. python wrote: > Hi everyone, > I have a file with this content: > > "1 > 1 > 1 > 1 > 1 > 1 > 1 > 2 > 1 > 1" > > I wanted a little script that would print the line containing "2" and > every line containing "1" after it. I've tried this: > > >>> def p(): > f = file("prueba.txt",'r') >

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Luis N
On Dec 16, 2007 10:17 PM, jon vs. python <[EMAIL PROTECTED]> wrote: > Hi everyone, > I have a file with this content: > > "1 > 1 > 1 > 1 > 1 > 1 > 1 > 2 > 1 > 1" > > I wanted a little script that would print the line containing "2" and every > line containing "1" after it. I've tried this: > > >>>

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Bob Gailer
[snip] now ponder this: f=file("prueba.txt.log") for startline in f: if startline.find("2") != -1: for endline in f: print endline # etc. ___ Tutor maillist - Tutor@python.org htt

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread bob gailer
Luis N wrote: > On Dec 16, 2007 10:17 PM, jon vs. python <[EMAIL PROTECTED]> wrote: > >> Hi everyone, >> I have a file with this content: >> >> "1 >> 1 >> 1 >> 1 >> 1 >> 1 >> 1 >> 2 >> 1 >> 1" >> >> I wanted a little script that would print the line containing "2" and every >> line containing "1

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Kent Johnson
jon vs. python wrote: > Hi everyone, > I have a file with this content: > > "1 > 1 > 1 > 1 > 1 > 1 > 1 > 2 > 1 > 1" > > I wanted a little script that would print the line containing "2" and > every line containing "1" after it. I've tried this: > > >>> def p(): > f = file("prueba.txt",'r')

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Alan Gauld
"jon vs. python" <[EMAIL PROTECTED]> wrote in > I wanted a little script that would print the line containing "2" > and every > line containing "1" after it. I've tried this: > def p(): >f = file("prueba.txt",'r') >for startline in f.read(): >if startline.find("2") != -1: >

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Alan Gauld
"Alan Gauld" <[EMAIL PROTECTED]> wrote > found2 = False > for line in file("prueba.txt"): > if '2' in line: found2 = True > if found2: print line > else: continue Just after posting I realised it would be better to do: found2 = False for line in file("prueba.txt"): found2 = foun

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Hans Fangohr
Dear all, thanks to everybody who replied to my question. On 15 Dec 2007, at 16:34, Kent Johnson wrote: > Ricardo Aráoz wrote: >> Kent Johnson wrote: >>> I don't know the answer, but it has nothing to do with the logging >>> module. The question is, can the same file reliably be opened >>> twi

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Kent Johnson
Hans Fangohr wrote: > Dear all, > > thanks to everybody who replied to my question. > > On 15 Dec 2007, at 16:34, Kent Johnson wrote: > >> Ricardo Aráoz wrote: > What is the recommended method to make such a suggestion to the python > team, or the people who look after the logging module? You

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Ricardo Aráoz
Hans Fangohr wrote: > Dear all, > > thanks to everybody who replied to my question. > > On 15 Dec 2007, at 16:34, Kent Johnson wrote: > >> Ricardo Aráoz wrote: >>> Kent Johnson wrote: I don't know the answer, but it has nothing to do with the logging module. The question is, can the sa

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Ricardo Aráoz
Kent Johnson wrote: > Hans Fangohr wrote: >> Dear all, >> >> thanks to everybody who replied to my question. >> >> On 15 Dec 2007, at 16:34, Kent Johnson wrote: >> >>> Ricardo Aráoz wrote: > >> What is the recommended method to make such a suggestion to the python >> team, or the people who look

Re: [Tutor] python logging module: two handlers writing to the same file - okay?

2007-12-16 Thread Kent Johnson
Ricardo Aráoz wrote: > Why should it be all or nothing. Couldn't the programmer indicate that > both handlers use the same file? It would be very easy to do this using StreamHandlers instead of FileHandlers. It would also be easy to make a FileHandler subclass that keeps a map from file name to

[Tutor] python links

2007-12-16 Thread Mark Alexiuk
Hi All, I have no experience using Python in an embedded application (industrial microcontrollers) but I'm sure it can be done and feel that Python offers many advantages for new OOP developers over C++. I would appreciate any suggestions on embedded processors compatible with Python or some vari

Re: [Tutor] python links

2007-12-16 Thread Michael Langford
Cross compiling python can be a bit of a bear. There build process has python scripts that assume that you're building python for the machine you are building on. There is a patch to help for that which Chris Lambacher has recently updated: http://whatschrisdoing.com/blog/2006/10/06/howto-cross-com