Teaching Programming
superpollo
utente at esempio.net
Tue May 4 08:46:52 EDT 2010
Stefan Behnel ha scritto:
> superpollo, 04.05.2010 13:56:
>> Stefan Behnel ha scritto:
>>> The question is: why do you have to generate the above code in the
>>> first place? Isn't a function enough that does the above?
>>
>> of course! *but* if i must generate on-the-fly python code that defines
>> a function [...]
>
> Well, could you provide a use case where you have to generate Python
> code, and where normally written code with some kind of parametrisation
> won't work?
i see your point, and mr mills gave me hints as to how to attack some of
my problems in such a fashion.
> The only thing that currently comes to my mind is a template compiler
> that translates a user provided template into an executable Python
> program. But that should be pretty trivial to do as well. I just
> remembered this little thing on Fredrik's effbot site, which should help
> here:
>
> http://effbot.org/zone/python-code-generator.htm
very good. i will most certainly give it a try.
but i do not think i can use it myself, since my template system wants
the input to generate the code to stay on a single line ( don't ask :-( )
bye
More information about the Python-list
mailing list