Is exec() also not used in python 2.7.1 anymore?

Chris Rebert clp2 at rebertia.com
Tue Oct 4 04:26:04 EDT 2011


On Tue, Oct 4, 2011 at 12:51 AM, Wong Wah Meng-R32813
<r32813 at freescale.com> wrote:
> In migrating my application from python 1.5.2 to 2.7.1, one of my modules
> breaks when I import it. Here is the line where it breaks. Can I have a
> quick check if this built-in function still supported in python 2.7.1

Er, `exec` is a primitive statement, not a built-in function (so, the
parens around it are superfluous), but yes, it's still present in 2.7.
(Ironically, exec was changed to a function in Python 3.0.)

> and if
> so, what ought to be changed here? Thanks in advance for replying.
>
>   exec('def %s(self, *args, **kw): pass'%methodStrName)

Defining a do-nothing, dynamically-named function seems kinda strange
in the first place; why are you doing this?

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list