Context managed code generation
ahopkins opened this issue · comments
Adam Hopkins commented
Re code generation: maybe take that a step forward and use actual inline Python code instead of string literals. Code that is syntactically valid can be loaded even if the variables don't exist, provided that the particular path never gets executed. Annotations or some other hacks could be used to inject parts into it. Well, you get the idea but this is becoming some true black magic by now.
# This is router code
if need_foo:
with codegen:
# This is generated code
if route == "foo":
return handler_foo
Originally posted by @Tronic in #37 (comment)