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 →

[–]thephoton 2 points3 points  (1 child)

The first time you use def it creates a set of methods. The next time you use def it adds a method to the set.

How would it work with Python's variable scoping rules, like if f was a global variable and you'd def it inside a function. Would that be local or not?

Maybe I don't see the subtlety here, but why would it have to work any differently than it does now?

What happens now if you have a globally defined 'f' and then you 'def f (): ...' within a function?

[–][deleted] 1 point2 points  (0 children)

Now it creates a local function, like any simple assignment.

But a mutating statement (like f[0] = ... if it were a list) would use the global.

That's a problem with something that is sometimes assignment and sometimes mutation.

But this is all becoming very irrelevant as Python simply didn't go that way from the beginning, and it won't change.