5 ms·
> There is something of a culture in Python of not being overly clever, which keeps this stuff in check. (Contrast Ruby, which offers equally powerful language
by falsedan 9y ago
> There is something of a culture in Python of not being overly clever, which keeps this stuff in check. (Contrast Ruby, which offers equally powerful language facilities without the cultural norm of not using them for crazy things.)
Have you seen namedtuple? It's part of the stdlib… and metaclasses are designed for devs to do wildly unpredictable actions when creating instances (not to mention python's OO layer is basically a clever hack).
- icebraining 9y ago"Keeping in check" is not the same as "not allowing". It has metaclasses, but they're rarely used. namedtuples are also a rare case in a large stdlib. How is the OO layer a clever hack?
- falsedan 9y agoMost other OO languages can pass self implicitly, and don't distinguish between initialization & construction. > There is something of a culture in Python of not being overly clever This is the part I disagree with. So much python I read in apps, libraries, web frameworks, and pythonista tweets is needlessly clever.
- icebraining 9y agoMost other OO languages can pass self implicitly That's not an hack, it's a conscious decision[1]. It actually avoids having to implement hacks, in the case of decorators; for example, @classmethod and @staticmethod can be implemented in pure Python thanks to that. It also avoids all the crap that litters JavaScript code, like "var self = this" and bind(), since you can just use different names to those variables. Implicit "this" works in Java and similar because the language is so restricted anyway that an explicit version would be useless. and don't distinguish between initialization & construction. Fair enough, but are they able to do what __new__ does? This is the part I disagree with. So much python I read in apps, libraries, web frameworks, and pythonista tweets is needlessly clever. But compared to which languages? [1] http://neopythonic.blogspot.be/2008/10/why-explicit-self-has-to-stay.html http://neopythonic.blogspot.be/2008/10/why-explicit-self-has...
- falsedan 9y agoFrom that link: > There's no way without knowing what the decorator does whether to endow the method being defined with an implicit 'self' argument or not. How about letting the code object decide if it's a method or a function, using a meta-object protocol to track when a code object is a method? Frankly, Guido's arguments boil down to "I can't see a nice way to not have it", not "here's a good reason to prefer this style". > But compared to which languages? Plain python.
- icebraining 9y agoHow about letting the code object decide if it's a method or a function, using a meta-object protocol to track when a code object is a method? Frankly, Guido's arguments boil down to "I can't see a nice way to not have it", not "here's a good reason to prefer this style". That would add complexity to the implementation and use to solve a specific problem, while leaving others unsolved. In any case, disagreeing with a decision doesn't make it a hack. Plain python. Fine, but I think the claim is that Python's culture avoids being overly clever compared to the culture of languages that offer similar possibilities. Being overly clever in your personal view is inherently subjective and therefore unarguable.
- falsedan 9y ago> That would add complexity to the implementation That's the job of a good language: to move the necessary complexity to the core, so users of the language do not have to address it by being clever. > Being overly clever in your personal view is inherently subjective and therefore unarguable non sequitur: I write the most boring plain python that can get the job done. I see other prolific python devs reveling in writing obtuse code (probably as jokes? frustrated standup comics?)
- vram22 9y ago>> There is something of a culture in Python of not being overly clever >This is the part I disagree with. So much python I read in apps, libraries, web frameworks, and pythonista tweets is needlessly clever. Can you give some examples? I'm not saying you're right or wrong, would just like to see some.
- falsedan 9y agoI gave examples in the GP of the post you’re replying to: namedtuple and metaclasses.