Re-executing the code object from a class 'declaration'

Carlos Ribeiro carribeiro at gmail.com
Wed Oct 6 11:10:21 EDT 2004


On 5 Oct 2004 23:33:01 -0700, Michele Simionato
<michele.simionato at gmail.com> wrote:
> which does something close to what you ask for. Of course the trick
> there is NOT recommended for real code ;)

That was the best advice I could have :-) Really. I'm trying to outwit
Python, and one has to have the good sense to stop doing it at some
point. I'm giving up (unless I found a really great way to make it),
and I'll use this idiom instead:

def BuildTemplate(<template parameters>)
    class TemplateClass(...):
        ...
    return TemplateClass

It's simple, and less hackish, but still unusual. I fear I may be
missing something on my design, if I need to resort to such hacks.
-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list