Nested stream line iteration
Jim Meier
jim at dsdd.org
Wed Jul 31 04:24:22 EDT 2002
On Tue, 30 Jul 2002 06:11:57 -0600, Lars Lundgren wrote:
[snip]
> for line in fileinput.input(filename):
> [m,t] = string.split( line )
> build( m,t )
>
[snip]
> When I run it I get the following error:
>
> raise RuntimeError, "input() already active"
> RuntimeError: input() already active
>
> As I understand it, this means that it is not allowed to nest input() like
> I do. Is that correct?
>
> Then is there a working solution to my problem?
>
I don't know about fileinput, but the idiom i would use here is a simple:
for line in open(filename).readlines():
...(stuff)..
-Jim
More information about the Python-list
mailing list