Das gelingt mir spontan aber nicht:
Code: Alles auswählen
code = """def displayself(tpldata):
page=[]
page.append('<table border=0 cellpadding=0 cellspacing=0>')
if tpldata.has_key('colorrow'):
for item_colorrow in tpldata['colorrow']:
page.append(' <tr><td width="10%%">%s</td>' %(item_colorrow.get('color','')))
if item_colorrow.has_key('colorcol'):
for item_colorcol in item_colorrow['colorcol']:
page.append(' <td bgcolor="%s"> </td>' %(item_colorcol.get('code','')))
page.append(' </tr>')
page.append(' </table>')
return page"""
template_pyc = compile(code, "<string>", 'exec')
print template_pyc
Und ich dachte ich erhalte somit einen Binär-Bytecode?!?! Das code-objekt hat auch keine brauchbaren Methoden:
- __class__
__cmp__
__delattr__
__doc__
__getattribute__
__hash__
__init__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__str__
co_argcount
co_cellvars
co_code
co_consts
co_filename
co_firstlineno
co_flags
co_freevars
co_lnotab
co_name
co_names
co_nlocals
co_stacksize
co_varnames