[Python-Dev] exec documentation

Terry Reedy tjreedy at udel.edu
Sat Jan 10 00:40:08 CET 2009


Glenn Linderman wrote:
> in 2.6 and before execfile is listed in builtin functions, and is not 
> marked deprecated, and exec is in the simple statements, and is not 
> marked deprecated.

Because they are not going away in 2.7.

> in 3.0 execfile is not listed in builtin functions, exec is.  exec is 
> not listed in simple statements.

All as appropriate.

> I guess this is an intended 3.0 change, but is this the proper way to 
> document it?

This is really a python-list/c.l.p question:  Anyway... What's new 3.0: 
"exec() is no longer a keyword; it remains as a function."..."Removed 
execfile(). Instead of execfile(fn) use exec(open(fn).read()). " ...Yes.

> What I was really trying to figure out is how I could specify the 
> encoding of a file to be execfile'd in 2.6... but didn't find it so 
> thought I'd try 3.0 to see if it would assume UTF-8, but had forgotten 
> execfile doesn't exist in 3.0 (if I knew it; I'm new here).

Ditto - how to use current 3.0, not how to develop 3.0.1/3.1.  Anyway, 
specify encoding in the open function.

tjr



More information about the Python-Dev mailing list