"Steve Holden" schrieb
>
> I simply meant that the whole source has to be presented
> to the exec statement and not chunked into lines.
>
That's what I meant: With exec open(f).read() it is not
broken into several exec invocations.
>
> I was probably just a little over-zealous in pursuing
>
Martin Blume wrote:
> "Steve Holden" schrieb
>>> [ difference between exec open(fname).read()
>>>and for line in open(fname): exec line ]
>>>
>>> So it seems to depend on the way the file is read.
>>>
>> It depends on the way the lines of the file are executed,
>> not how they are read.
>>
"Steve Holden" schrieb
> >
> > [ difference between exec open(fname).read()
> >and for line in open(fname): exec line ]
> >
> > So it seems to depend on the way the file is read.
> >
> It depends on the way the lines of the file are executed,
> not how they are read.
>
Could you elaborate
On Fri, 18 May 2007 04:45:30, Dennis Lee Bieber <[EMAIL PROTECTED]>
wrote
>On 17 May 2007 13:12:10 -0700, i3dmaster <[EMAIL PROTECTED]> declaimed
>the following in comp.lang.python:
>
>> 'b' is generally useful on systems that don't treat binary and text
>> files differently. It will improve porta
Martin Blume wrote:
> "Steve Holden" schrieb
Try it on a file that reads something like
xxx = 42
print xxx
and you will see NameError raised because the assignment
hasn't affected the environment for the print statement.
>>> [...]
>>>
>> No, because there i
On May 17, 3:02 am, Douglas Woodrow <[EMAIL PROTECTED]>
wrote:
> On Thu, 17 May 2007 00:30:23, i3dmaster <[EMAIL PROTECTED]> wrote
>
> >f = open(file,'rb')
> >for i in f:
> >exec i
>
> Why are you opening the file in binary mode?
>
> --
> Doug Woodrow
'b' is generally useful on systems tha
"Steve Holden" schrieb
> >>
> >> Try it on a file that reads something like
> >>
> >> xxx = 42
> >> print xxx
> >>
> >> and you will see NameError raised because the assignment
> >> hasn't affected the environment for the print statement.
> >>
> > [...]
> >
> No, because there isn't one. Now try
Steve Holden a écrit :
> i3dmaster wrote:
>> On May 16, 1:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>>> Martin Blume wrote:
"tmp123" schrieb >
> We have very big files with python commands
> (more or less, 50 commands each file).
> It is possible to execute them command by
i3dmaster wrote:
> On May 16, 1:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Martin Blume wrote:
>>> "tmp123" schrieb >
We have very big files with python commands
(more or less, 50 commands each file).
It is possible to execute them command by command,
>>> inp = open(cmd_fi
On Thu, 17 May 2007 00:30:23, i3dmaster <[EMAIL PROTECTED]> wrote
>f = open(file,'rb')
>for i in f:
>exec i
Why are you opening the file in binary mode?
--
Doug Woodrow
--
http://mail.python.org/mailman/listinfo/python-list
On May 16, 1:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Martin Blume wrote:
> > "tmp123" schrieb >
> >> We have very big files with python commands
> >> (more or less, 50 commands each file).
>
> >> It is possible to execute them command by command,
>
> > inp = open(cmd_file)
> > for line
Martin Blume wrote:
> "tmp123" schrieb >
>> We have very big files with python commands
>> (more or less, 50 commands each file).
>>
>> It is possible to execute them command by command,
>
> inp = open(cmd_file)
> for line in inp:
> exec line
>
> might help. You don't get quite the sam
"tmp123" schrieb >
> We have very big files with python commands
> (more or less, 50 commands each file).
>
> It is possible to execute them command by command,
inp = open(cmd_file)
for line in inp:
exec line
might help. You don't get quite the same feeling as
"like if the commands wa
tmp123 wrote:
> Hello,
>
> Thanks for your time.
>
> We have very big files with python commands (more or less, 50
> commands each file).
>
Those are BIG programs. Presumably other programs are writing them?
> It is possible to execute them command by command, like if the
> commands was typ
In <[EMAIL PROTECTED]>, tmp123 wrote:
> We have very big files with python commands (more or less, 50
> commands each file).
>
> It is possible to execute them command by command, like if the
> commands was typed one after the other in a interactive session?
Take a look at the `code` module
15 matches
Mail list logo