[Python-ideas] Ruby-style Blocks in Python Idea

Mathias Panzenböck grosser.meister.morti at gmx.net
Mon Mar 9 18:11:20 CET 2009


tav wrote:
 > Hey all,
 >
 > I've come up with a way to do Ruby-style blocks in what I feel to be a
 > Pythonic way:
 >
 >   using employees.select do (employee):
 >       if employee.salary > developer.salary:
 >           fireEmployee(employee)
 >       else:
 >           extendContract(employee)
 >

Maybe if you come up with an example that isn't written with already existing 
python syntax as easy (or even more easily):

for employee in employees: # or employees.select() if you like
	if employee.salary > developer.salary:
		fireEmployee(employee)
	else:
		extendContract(employee)


	-panzi



More information about the Python-ideas mailing list