3 ms·
Try this on the python source itself and you'll find a lot of perfectly reasonable examples. One problem is that in a method, your first meaningful indent is ac
by pvg 10y ago
Try this on the python source itself and you'll find a lot of perfectly reasonable examples. One problem is that in a method, your first meaningful indent is actually three (12 spaces in) - two are eaten up in declaration ceremony. In a language with delimiters instead of significant whitespace you could just fiddle with the convention - for instance, you could decide that you're just not going to give up a full indent for toplevel class members. This isn't an option in Python.
- chriswarbo 10y ago> One problem is that in a method, your first meaningful indent is actually three (12 spaces in) - two are eaten up in declaration ceremony. I think that's just as reasonable as the rest of Python's whitespace usage, since it (hopefully!) causes the programmer to consider whether that ceremony (classes, methods, etc.) is neccessary or just overcomplication. It's directly comparable to, say, nesting lambdas in lambdas in lambdas; probably not great for readability, etc. It just-so-happens that in Python's OO, that first lambda is called a class and the second is called a method (objects are a poor man's closures, and closures are a poor man's object!)
- pvg 10y agoFor all the 'multi-paradigm' talk, it's still mostly an OO language and almost everything non-trivial written in python is structured in classes and methods. So that's 12 spaces with your first real indent. It's not the end of the world (nor do I think it's there to discourage one from using classes and methods) but it makes it easy enough to hit 80 chars to the point where a strict 80 column limit is a little too restrictive.