How to define "exec" method on a class object? Get syntax error due to built in command

Steven D'Aprano steve+comp.lang.python at
Wed Mar 27 00:19:17 CET 2013

On Wed, 27 Mar 2013 06:39:24 +1100, Chris Angelico wrote:

> On Wed, Mar 27, 2013 at 6:24 AM, Kyle <stalkernew at> wrote:
>> On Mar 26, 2:43 pm, Chris Angelico <ros... at> wrote:
>>> On Wed, Mar 27, 2013 at 5:13 AM, Kyle <stalker... at> wrote:
>>> > Thanks for the suggestion. Looks like we currently use 2.3.4.
>>> > This still wouldn't solve the problem because now the user would
>>> > need to call something like  getattr(wbt, "exec")(<args>) instead of
>>> > wbt.exec(<args>) like all the other commands.
>>> > I think the easiest thing for me to do would be to just change the
>>> > command name from exec to something else.
>>> ..... that's pretty ancient. Any chance you can upgrade at least to
>>> 2.7.3?
>>> ChrisA
>> Unfortunately, while I could update my machine, there's no guarantee
>> others would have the same version--the 2.3.4 seems to be the default
>> on our machines and in the automount dirs.
> I strongly recommend upgrading. 2.3.4 dates back to 2004, that's roughly
> a decade of bug fixes and feature enhancements behind the times. 

Python 2.3 is still supported by Red Hat, at least if you have paid for 
extended support. In principle at least, Red Hat will be providing 
security fixes for 2.3.

> 2.7.3
> is the latest 2.x release, and most likely your code will run unchanged
> on it; if you can switch to 3.3.0 (the latest 3.x release), that would
> actually fix your exec problem, for what that's worth. (Moving to 3.3.0
> would be a much bigger change, though, and one that's likely to require
> code edits.)

If the OP's code uses string exceptions:

raise "an error occurred"

they will need to be replaced before migrating to 2.7.


More information about the Python-list mailing list