from future import pass_function

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Thu Jul 26 02:39:25 EDT 2012


Am 25.07.2012 18:05, schrieb Chris Angelico:
> By comparison, Python 2's print statement is executable. It causes
> real action to happen at run-time. It makes sense to pass "print" as
> an argument to something; for instance:
>
> def some_generator():
>     yield blah
>
> map(print,some_generator())
>
> Simple way of making the iterator display its yielded result. I cannot
> imagine any circumstance in which you'd want to map "pass" over
> everything.

I have seen code that just created a list comprehension to iterate over 
something but was discarding the results. That could be a case for a "do 
nothing" function.

Just having a function that does nothing would be useful in other 
places, too. In some cases, you want to print() some debug output in 
other cases you just use pass() to discard the debug output.

Uli



More information about the Python-list mailing list