Exec and Scope

Emanuele D'Arrigo manu3d at gmail.com
Fri Oct 31 11:38:12 EDT 2008


On Oct 31, 3:56 am, "James Mills" <prolo... at shortcircuit.net.au>
wrote:
> Good lord man, what are you trying to solve ?
> Describe your "actual problem" you're attempting
> to solve... This looks really really ugly and I would
> advise against any solution that relies on exec()

I knew I was going to get some lighting bolt from the community... =)
It wasn't quite elegant, was it? =)

Let's see if I can describe the problem without writing a treaty about
it: I'm trying to implement a command queue manager. It can handle
multiple queues that run in parallel and each queue is made of a list
of arbitrary commands stored as strings. The commands are not
necessarily executed immediately but might have a delay. But commands
in an individual queue are executed in a strict first-in, first-out
order.

The machinery to handle the delays is provided by a third-party API
I'm using. But it only handles actual code, not string commands. But
at this stage when I place a command into the queue, only built-in
commands are executed correctly. Methods that are part of an object
are not. Which make sense: when the command is executed its
environment doesn't know about that particular object. And that's
where I'm stuck. I suspect I need to reshape the whole thing but at
this point I don't quite know how.

Manu




More information about the Python-list mailing list