4 ms·
My biggest issue at this point is the implicit scoping. I've been using Python for 8 years (as well as a bunch of other languages, both for work and personally)
by masklinn 14y ago
My biggest issue at this point is the implicit scoping. I've been using Python for 8 years (as well as a bunch of other languages, both for work and personally), and — while a lost cause, it won't be changed at this point — I've come to believe it was a Really Bad Idea[0].
Not only does it make bindings awkward (and sometimes broken, in different ways depending on the way "scope inference" is implemented) and tends to hide errors (e.g. typo) or generate them much later than possible (even though lexical checking is very cheap to perform at parse time, with explicit scopes), it has pretty much no actual benefit I can think of.
Especially in Python where assignment is a statement, not an expression, so it's not like explicit scoping would prevent putting assignments in place they're currently allowed.
[0] and it's one of the things I find utterly retarded in coffeescript.
- emidln 14y agoassignment is a statement if you want it to be, but you can generally use setattr() as well. E.g. modifying global scope as an expression: import sys module = sys.modules[__name__] def foo(k,v): setattr(module, k, v) foo('spam','eggs') assert(spam == 'eggs')
- masklinn 14y agoThat only "works" for the global scope, or by chance in some cases in the local scope if you do a star-import within the local scope (yeah…) I don't consider that working, it's a piling up of hacks. Which is great when you need them and they work, but... Also, there's a simpler way to implement your snippet: globals().__setitem__('spam','eggs')
- deleted 14y ago[deleted]