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")
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')
>
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:
>
> >>>
[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
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
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')
"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:
>
"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
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
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
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
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
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
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
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
15 matches
Mail list logo