An idiom for code generation with exec

Peter Otten __peter__ at web.de
Fri Jun 20 08:44:46 EDT 2008


eliben wrote:

> Additionally, I've found indentation to be a problem in such
> constructs. Is there a workable way to indent the code at the level of
> build_func, and not on column 0 ?

exec "if 1:" + code.rstrip()

Peter




More information about the Python-list mailing list