from future import pass_function

I

Ian Kelly

I had very similar thoughts about eight months ago, and posted them here:

https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/CB_5fek2b8A

I'm no computer science guru, but the idea that pass should be a function rather than a statement continues to appeal to me. As you can see, I actually wrote just such a function so that I could use it as an argument in my code.

As long as 1) the name can't be reassigned (like None) and 2) the
compiler is able to optimize it out when used by itself as a statement
(to avoid incurring the expense of a common but pointless name
lookup), then I kind of agree. The added complexity of those two
restrictions detracts a bit from the appeal to elegance, though.
 
E

Ethan Furman

John said:
When I brought up this same issue some months ago...

https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/CB_5fek2b8A

...it wasn't because I wanted to pass parameters to "pass", it was because I wanted to define a do-nothing function as an optional behavior within another function. In other words, I wanted to pass "pass."

That's a reasonable thing to want, and quite easily accomplished by
passing `lambda: None` or `lambda *args, **kwargs: None` instead. I
don't think this is difficult to do, nor common enough to justify making
every other `pass` a time-consuming do-nothing operation, instead of
just a do-nothing operation

~Ethan~
 
J

John Ladasky

That's a reasonable thing to want, and quite easily accomplished by
passing `lambda: None` or `lambda *args, **kwargs: None` instead.

That's the same solution that Steven D'Aprano proposed the last time we had this discussion. Which, I agree, is reasonable (although I continue to have a certain instinctive aversion to lambda).
 
J

John Ladasky

That's a reasonable thing to want, and quite easily accomplished by
passing `lambda: None` or `lambda *args, **kwargs: None` instead.

That's the same solution that Steven D'Aprano proposed the last time we had this discussion. Which, I agree, is reasonable (although I continue to have a certain instinctive aversion to lambda).
 
E

Ethan Furman

John said:
I had very similar thoughts about eight months ago, and posted them here:

https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/CB_5fek2b8A

I'm no computer science guru, but the idea that pass should be a function rather than a statement continues to appeal to me. As you can see, I actually wrote just such a function so that I could use it as an argument in my code.

I would have called `no_op` or `nop` -- `pass` does just what it says:
it passes and does zero work. Your _pass does do work, just useless
work. Sometimes that's necessary, but I wouldn't call it `_pass`.

~Ethan~
 
M

Mark Lawrence

I thought Ranting Rick had sole dominion over trolling?

Incorrect. Yes he can be a PITA but when he writes about tkinter/idle
he appears to know what he's talking about. I much prefer that to The
World's Leading Expert On Writing Documentation aka Xah Lee who must
spend his entire life sittng down as his voice is so muffled.
 
M

Mark Lawrence

Certainly not. We are well endowed with trolls here (Xah Lee isn't
prolific, but is certainly effective), plus we have some regular
posters who'll cover the trolls' tea breaks on occasion (myself,
sometimes, and Steven D'Aprano).

Now where did I put my asbestos suit... the Aprano is going to be at
me pretty hard for this...

Are you nuts, asbestos? My tin hat, camouflage net and trenching tool
are very much safer :)
 
T

Terry Reedy

I had very similar thoughts about eight months ago, and posted them
here:

https://groups.google.com/forum/?fromgroups#!topic/comp.lang.python/CB_5fek2b8A

I'm no computer science guru, but the idea that pass should be a
function rather than a statement continues to appeal to me.

A do nothing statement is standard in statement based languages. It is
not going away.
can see, I actually wrote just such a function so that I could use it
as an argument in my code.

For one time use: lambda:None

For multiple use: def none: pass # same as return None in this context

A function needs a lot more meat than that to be added as a builtin.
 
U

Ulrich Eckhardt

Am 26.07.2012 09:50, schrieb Mark Lawrence:
And if we could persuade the BDFL to introduce braces, we could have {()
and }()

What do you mean "persuade"? Braces work perfectly:

def foo():
{}

<grin, duck and run faster as the impacts get closer>

Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Strange effect with import 9
Import redirects 0
Question about import hooks 0
Naming future objects and their methods 2
simple import hook 0
Import order question 0
import bug 15
A thread import problem 0

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top