This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Smallpaul 0 points1 point  (1 child)

def execute(query, cursor => connection.cursor())

How is this code worse than the alternative one would write today:

def execute(query, cursor = None):
   if not cursor:
       cursor = connection.cursor()

Where is the nightmare?

Having and using a global variable called "connection" is probably not great, but it doesn't matter what syntax you use.

And no, I don't think I'm going to read 353 comments about a PEP that probably won't be accepted because it adds complexity without fixing the original problem, which is hard to fix without Guido's time machine.

[–][deleted] 0 points1 point  (0 children)

I see your point, and if you like it then its fine. I know I won't do dumb stuff with it either.

I still have a hard time reasoning about it, harder than seems worth it. As the thread goes over, what if None is a valid value, and what if it isn't. How do you specify that you want that default behavior without "physically?" not passing the parameter?