Python 3: exec arg 1
tjreedy at udel.edu
Sat Jan 17 22:20:49 CET 2009
Alan G Isaac wrote:
> In Python 3, you can no longer ``exec(open(filename))``.
> I guess the reason is that in 3.0 ``open`` returns a stream,
> instead of open file, and exec wants
> "a string, bytes, or code object" and not a "TextIOWrapper".
> So it returns an error.
> Is it intentional that ``exec`` cannot handle a TextIOWrapper?
> Bottom line: has ``execfile(filename)`` really become
> ``exec(open(filename).read())``? Is this a good thing?
More information about the Python-list