You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In 2.5, exec(open(filename)), where filename refers to a file with
python code, executes the code.
In 2.5, open returns an open file, but in 3.0, open returns a stream,
and so exec (which wants "a string, file, or code object, not
TextIOWrapper") returns an error. exec should probably be able to handle
a stream.
There is also a class of functions 'exec*' (and a related class,
'spawn*') in Lib/os.py that claims to do just what you want, but
replacing the current process (or, in spawn*'s case, in a new thread).
That said, I agree that exec should handle streams, and if you could
give me a heads up as to where the code is for exec(), I could try my
hand at a patch.
ms commented on Jun 24, 2008
msmannequin
MannequinAuthor
More actions
I'm actually quite new to Python. My current interpreter of choice is
PostScript, followed by Matlab, but I've been discouraged from using
either one here at EMC. (PostScript because it's obscure, Matlab because
it's expensive!)
Meanwhile, I'm on a wintel machine, making perusing the Python source
tree difficult. So I'm not going to be much help in that regard.
By the way, I was told that execfile is gone from python 3.
By the way, I was told that execfile is gone from python 3.
It certainly isn't in the branch I just checked out.
leifwalsh commented on Jun 24, 2008
leifwalshmannequin
Mannequin
More actions
(isn't gone, that is)
ms commented on Jun 24, 2008
msmannequin
MannequinAuthor
More actions
Well, I think I found exec in bltinmodule.c,
but execfile isn't in that file. [In the 3.0 tree.]
leifwalsh commented on Jun 24, 2008
leifwalshmannequin
Mannequin
More actions
execfile is in Lib/idlelib/PyShell.py, and is an instance function, so
it's not really standard for regular code, and would also be hard to
use correctly. Sorry.
Activity
ms commentedon Jun 24, 2008
In 2.5, exec(open(filename)), where filename refers to a file with
python code, executes the code.
In 2.5, open returns an open file, but in 3.0, open returns a stream,
and so exec (which wants "a string, file, or code object, not
TextIOWrapper") returns an error. exec should probably be able to handle
a stream.
leifwalsh commentedon Jun 24, 2008
There's 'execfile' in Lib/idlelib/PyShell.py...I'm looking for others.
There is also a class of functions 'exec*' (and a related class,
'spawn*') in Lib/os.py that claims to do just what you want, but
replacing the current process (or, in spawn*'s case, in a new thread).
That said, I agree that exec should handle streams, and if you could
give me a heads up as to where the code is for exec(), I could try my
hand at a patch.
ms commentedon Jun 24, 2008
I'm actually quite new to Python. My current interpreter of choice is
PostScript, followed by Matlab, but I've been discouraged from using
either one here at EMC. (PostScript because it's obscure, Matlab because
it's expensive!)
Meanwhile, I'm on a wintel machine, making perusing the Python source
tree difficult. So I'm not going to be much help in that regard.
By the way, I was told that execfile is gone from python 3.
--ms
leifwalsh commentedon Jun 24, 2008
On Tue, Jun 24, 2008 at 3:05 PM, Mike Speciner <report@bugs.python.org> wrote:
It certainly isn't in the branch I just checked out.
leifwalsh commentedon Jun 24, 2008
(isn't gone, that is)
ms commentedon Jun 24, 2008
Well, I think I found exec in bltinmodule.c,
but execfile isn't in that file. [In the 3.0 tree.]
leifwalsh commentedon Jun 24, 2008
execfile is in Lib/idlelib/PyShell.py, and is an instance function, so
it's not really standard for regular code, and would also be hard to
use correctly. Sorry.
brettcannon commentedon Jun 25, 2008
bpo-1762972 supercedes this.