"John Machin" <[EMAIL PROTECTED]> writes:
> Mike Meyer wrote:
>>
>> I've discovered a truly elegant trick with python programs that
>> interpret other data.
> Q0. Other than what?
Other than Python code.
>> You make them ignore lines that start with # at
>> the beginning of the line,
> Q1. After
Mike Meyer wrote:
>
> I've discovered a truly elegant trick with python programs that
> interpret other data.
Q0. Other than what?
> You make them ignore lines that start with # at
> the beginning of the line,
Q1. After the first user accidentally gets a # at the start of a real
data line, a fe
"B.G.R." <[EMAIL PROTECTED]> writes:
> Hi all,
>
> I'm working on an interpreter for a university subject, which is programmed
> in python under linux.
> I got most of the work done and I'm just trying to settle some problems I've
> found on my way.
> Right now, the most important is reading the u
B.G.R. wrote:
numline=0
for line in sys.stdin:
numline+=1
workwithline(line)
I'd use:
for numline, line in enumerate(sys.stdin):
workwithline(line)
Note: The line numbers start at 0, but that is often acceptable.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/
"Alex Martelli" <[EMAIL PROTECTED]> escribió en el mensaje
news:[EMAIL PROTECTED]
> B.G.R. <[EMAIL PROTECTED]> wrote:
>...
> > numline=0
> > for line in sys.stdin:
> > numline+=1
> > workwithline(line)
>
> Consider the alternative:
> for numline, line in enumerate(sys.stdin):
>
> N
B.G.R. <[EMAIL PROTECTED]> wrote:
...
> numline=0
> for line in sys.stdin:
> numline+=1
> workwithline(line)
Consider the alternative:
for numline, line in enumerate(sys.stdin):
Nothing to do with your main program, but still neater...
> that's ok, but if the user only does "./myp
B.G.R. wrote:
> Hi all,
[snip]
> A little bit more complex, but that's the idea. That will work if the
user
> does something like "./myprog.py < code" or "cat code | ./myprog.py",
and
> that's ok, but if the user only does "./myprog.py" then I got to get
into
> interactive mode and show a prompt in
Hi all,
I'm working on an interpreter for a university subject, which is programmed
in python under linux.
I got most of the work done and I'm just trying to settle some problems I've
found on my way.
Right now, the most important is reading the user input. Everything goes
through the standard inp