Like this... I don't think the python style is very good, and reading and writing are not convenient. Now the editor is so convenient that Semicolons can be automatically completed. Do you think the Python style is good? (Image Source: twitter. comthedirtycoderstatus%339014085517312)
Like this... I don't think the python style is very good, and reading and writing are not convenient. Now the editor is so convenient that Semicolons can be automatically completed. Do you think the Python style is good?
(Source: https://twitter.com/thedirtycoder/status/569339014085517312)
) Reply: paste a Learning Python, 5th Edition-O' Reilly Media
Okay:
Why Indentation Syntax?
The indentation rule may seem unusual at first glance to programmers accustomed toC-like ages, but it is a deliberate feature of Python, and it's one of the main waysthat Python almost forces programmers to produce uniform, regular, and readable code. it essential means that you must line up your code vertically, in columns, ac-cording to its logical structure. the net effect is to make your code more consistent andreadable (unlike much of the code written in C-like versions ).
To put that more stronugly, aligning your code according to its logical structure is amajor part of making it readable, and thus reusable and maintainable, by yourself andothers. in fact, even if you never use Python after reading this book, you shoshould get into the habit of aligning your code for readability in any block-structured language. pythonunderscores the issue by making this a part of its syntax, but it's an important thing todo in any programming language, and it has a huge impact on the usefulness of yourcode.
Your experience may vary, but when I was still doing development on a full-time basis, I was mostly paid to work on large old C ++ programs that had been worked on bymany programmers over the years. almost invariably, each programmer had his or herown style for indenting code.
Forced indentation is actually a mechanism for Python to keep the code style uniform and readable.
At the same time, I do not sincerely wish those students whose code style is the same as shit that they think they are both awesome, witty, and personalized. They will not be co-operated by colleagues in the future. The pasted graph is Java... What python indentation do you use in java ......
I use
Pure pythonRewrite your code:
class Permuter: def permute(self, n, a): if n==0: print a else: for i in range(n+1): permute(n-1, a) self.swap(a, 0 if n%2 else i, n) def swap(self, a, i, j): a[i], a[j] = a[j], a[i]
In fact, any language uses indentation as a standard. Even if indentation does not make sense to the compiler, it increases readability. So since we have to indent all of them, there is no problem that Python is doing well.
All mainstream ides have the automatic layout function. You can try it. I mean the Automatic Layout of other languages. The Automatic Layout of Python cannot process the automatic indentation at the beginning of the statement. You can only change the distance between characters. This is something like python that forces you to normalize indentation. If you follow the rules, python directly saves the braces semicolon, and there is no other habit change. If you ignore indentation rules... Sorry, I really don't want to read code without indentation, and I believe I am not alone.
As for writing, I don't want to indent it, and then I will automatically indent it or something... It's crazy to write complicated things and make an estimation and make a mistake...
It is said that a java image has been swallowed up a lot, but you can't help but vomit... You can paste a syntax like a little... You... Post... ... Java... Dry... Well... Indentation solves the problem that curly braces should not be written with line breaks.
Now the editor is so convenient that the semicolon can be automatically completed.
I don't even want to write a semicolon. Why not use Python? Do not write it directly. :-D is not very good. You are still discussing this ?? Line breaks and indentation should be added to brackets,
Isn't it good to press the keyboard less once and automatically align it?