Ruby like syntactic sugar

A.M. Kuchling amk at amk.ca
Wed Mar 3 00:22:31 CET 2004


On 2 Mar 2004 13:26:17 -0800, 
	F Jamitzky <fxj at mpe.mpg.de> wrote:
> 5 *times(lambda: printf("Hello World!") )
> or
> [toast, cheese, wine] *each (lambda food: eat(food) )

These formulations are no improvement over the obvious code:

for i in range(5):
    print 'Hello world!'
    
or

for food in [toast, cheese, wine]:
    eat(food)

It's certainly possible to use Python language features to get Ruby-like
code, but this code isn't as clear, so why bother?

--amk



More information about the Python-list mailing list