Aaron Tp, 07.07.2012 23:19: > I have a question on using self-modifying code/code generation > in Python; namely how to do it.
Don't. Seriously, the answer you should ask yourself is: why do you think the genetic algorithm (or whatever you are trying to do exactly) would come up with any reasonable code constructs other than what you already anticipated? And if you anticipated them, you can just write them down statically in the code and only care about recombining them. Make your code configurable instead, and then change the configuration. I agree with Alan that a state machine could be a suitable approach (but it's a bit hidden in his long answer). In any case, think in terms of modifying data, not code. Stefan _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor