Using code objects?

Chinook chinook.nr at tds.net
Tue Jun 21 17:41:36 EDT 2005


On Tue, 21 Jun 2005 09:56:27 -0400, Konstantin Veretennicov wrote
(in message <4660fe3005062106565aab8536 at mail.gmail.com>):

> On 6/21/05, Chinook <chinook.nr at tds.net> wrote:
>> 
>> When I create the code objects though, it seems a couple different ways work
>> and I'm wondering which is better and why (or is there a more correct
>> technique in this situation)?
>> 
>> The two different ways are illustrated below:
> ...
>>>>> obj1 = compile(exp1, 'whatever', 'single')
> ...
>>>>> obj2 = compile(exp2, 'whatever', 'exec')
> 
> Are you essentially asking about difference between compile(..., 'single') 
> and compile(..., 'exec'), which is described in
> http://docs.python.org/lib/built-in-funcs.html ?
> 
> - kv

[I neglected to post this to the list]

Sorry Konstantin, being way too late at the time I missed the obvious.  Since 
I'll have multiple statements in a code object I will, of course, use 'exec'

In the meantime I have done a lot of searching and I guess the second point 
of the query is pretty well settled also, unless you have another thought.   
There are some number of code objects independent of some number of potential 
classes.  Each potential class "action' method will return one or more of the 
code objects.  So I 'compile' the code objects separately and pass back 
appropriate references from the factory derived class method.  

I'm intentionally over designing a simple utility so I will learn the 
techniques and alternatives for a more involved application that involves AI.
Thanks,
Lee C





More information about the Python-list mailing list