Python It is undoubtedly the most widely used programming language today , Especially in the era of artificial intelligence , It has become the main language for AI development , Even the language has been taught in the third grade of primary school . Why it's so popular , It's largely due to simple grammar and readability for all ages , This makes it very easy to use . The reason why beginners like Python, Because it feels like writing a piece of pseudo code in English .
however , No matter how much experience you have , No matter how many languages you've studied , Switch to Python There's no guarantee that you can make a smooth transition . It's easy for developers with an object-oriented programming background to ignore Python Common features of , Or say python Paradigm programming . thus , They are likely to misuse programming structures , Thus, it is possible to find something difficult to find 、 Unforeseen mistakes . What's worse is , Most of these mistakes are hard to find , And it may bring great trouble to the project , At the same time, it is easy to delete the library and run away , If you are heavy, you will hate for life .
In this paper , Programmers will be listed （ It's usually a rookie ） Common mistakes that can be made . Besides , I'll also show you how to avoid these mistakes , In order to write better 、 No mistake Python Code .
1） Use long chains of conditions and logic
In most languages , We all know to write some comparison logic in the following way ：
if a < b and b < c
Unlike most languages where adjacency operators cannot be used in non associative priorities ,Python Provides the ability to write chained assignments