Re: fileinput.input, readlines and ...

2009-06-24 Thread Private Private
On Jun 24, 1:32 pm, Peter Otten <[email protected]> wrote:
> Przemyslaw Bak wrote:
> > Hello,
>
> > I many files with log data. The structure of the file is quite
> > inconvenience and similar to the following example:
> > Data1
> >   ValueA
> > Data2
> >   ValueB
> > Data3
> >   ValueC
> > ...
> > To get the values I need to find Data* and then get to the next line.
> > I tried to use fileinput.input :
> > ...
> > for line in fileinput.input(filename):
> >     if line.find("Data2") >= 0:
> >         (now what ?)
>
> > So I can find the requested line (Data2) but how to get value from the
> > next line ?
>
> lines = fileinput.input(filename)
> for line in lines:
>     if "Data2" in line:
>         print line.strip(), "-->", next(lines).strip()

I get an error:

...
print line.strip(), "-->", next(lines).strip()
NameError: global name 'next' is not defined

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fileinput.input, readlines and ...

2009-06-24 Thread Private Private
On Jun 24, 11:00 pm, Peter Otten <[email protected]> wrote:
> Private Private wrote:
> > > lines = fileinput.input(filename)
> > > for line in lines:
> > >     if "Data2" in line:
> > >         print line.strip(), "-->", next(lines).strip()
>
> > I get an error:
>
> > ...
> >     print line.strip(), "-->", next(lines).strip()
> > NameError: global name 'next' is not defined
>
> In Python versions prior to 2.6 instead of
>
> next(lines)
>
> you can use
>
> lines.next()
>
> Peter

That works perfectly. Thank you :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fileinput.input, readlines and ...

2009-06-24 Thread Private Private
On Jun 24, 12:23 pm, Przemyslaw Bak  wrote:
> Hello,
>
> I many files with log data. The structure of the file is quite

Each requested value is in separated file.
While traversing using os.path.walk I have noticed that I get files
unsorted.
Is it possible to get them sorted ?

przemol
-- 
http://mail.python.org/mailman/listinfo/python-list


Python simple web development

2009-06-25 Thread Private Private
Hi,

I am looking for a python library which will allow me to do a simple
web development. I need to use
some forms (but nice looking :-) ), creating images based on input
from those forms, etc. I have read a bit about Django and TurboGears
but I am afraid that this is too big for my requirements (am I
wrong ?).

Can you suggest anything ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python simple web development

2009-06-25 Thread Private Private
On Jun 25, 10:59 am, Chris Withers  wrote:
> Private Private wrote:
> > from those forms, etc. I have read a bit about Django and TurboGears
> > but I am afraid that this is too big for my requirements (am I
> > wrong ?).
>
> You are wrong :-)

Why ?
What I've read about Django, Turbogears is that they are powerful
enough to create big web-based portals, applications, etc.
I need just simple forms without any sophisticated functionality.
So again: why I am wrong ?

przemol
-- 
http://mail.python.org/mailman/listinfo/python-list