--- On Tue, 5/4/10, Stefan Behnel <stefan...@behnel.de> wrote: > From: Stefan Behnel <stefan...@behnel.de> > Subject: Re: Teaching Programming > To: python-list@python.org > Date: Tuesday, May 4, 2010, 7:43 AM > superpollo, 04.05.2010 13:23: > > Stefan Behnel ha scritto: > >> the main reason why this problem doesn't hurt much > in Python > >> is that Python is a dynamic language that can get > you extremely far > >> without generating code. It's simply not necessary > in most cases, so > >> people don't run into problems with it. > > > > Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45) > > [GCC 4.3.3] on linux2 > > Type "help", "copyright", "credits" or "license" for > more information. > > >>> A,B=2,3 > > >>> if A>B: > > ... print A+B > > ... else: > > ... print A**B-B**2 > > ... > > -1 > > >>> A,B=3,2 > > >>> if A>B: > > ... print A+B > > ... else: > > ... print A**B-B**2 > > ... > > 5 > > > > tell me please: how can generate the same output > (depending on A and B) > > without control structure? i mean in a natural > "pythonic" way... > > 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? > > Stefan > > -- > http://mail.python.org/mailman/listinfo/python-list >
Just thought I'd add my $0.02 here. I wrote AsciiLitProg (http://asciilitprog.berlios.de/) in Python. It is a literate programming tool. It generates code from a document. It can generate code in any language the author wants. It would have been a LOT easier to write if it did not generate Python code. Python is a great language to write in (although I do wish it did a better job with closures). But it is a PITA to generate code for! -EdK Ed Keith e_...@yahoo.com Blog: edkeith.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list