Zero-based learning Python which pit entry Python how to avoid

Python Pit learn what to avoid? How zero-based introductory Python? Getting Started with Python is simple, concise syntax, powerful, very suitable for zero-based entry in the IT industry people to learn. With the advent of the era of artificial intelligence, companies have chosen to develop in Python, Python needs of employees and wages and benefits are also rising. Many people choose to learn Python, but zero-based learning Python must avoid jumped into the pit!

 

Zero-based learning Python which pit entry Python how to avoid

 

 

1, using the wrong variable. In Python, each variable must be assigned before use, the variable after variable assignment will be created. As a dictionary class variable internal processing, and follows the method resolution order (MRO).

2, the abuse of expression as a function of the parameter default values. Python allows developers to specify a default value for function arguments, although this is a feature of the language, but when the variable parameters, can easily lead to confusion.

3, misunderstanding Python scope of the rules. Python is based on the scope resolution LEGB rule, namely Local, Enclosing, Global, Built-in.

4, create a loop module dependencies. There is only one cycle to import Python itself is not a problem, if a module is imported, Python will not try to re-import. According to this, each module when attempting to access a function or variable, you may encounter some problems at runtime.

5, abnormal specify incorrect parameters. Correct method of capturing multiple exceptions in an exception statement specifying the first parameter as a tuple, the tuple contains all the caught exception. At the same time, using as keywords to ensure maximum portability, Python 2 and Python 3 support this syntax.

6, the conflict with the Python standard library module name. Python has a very rich library of modules, and supports "out of the box." Therefore, if you do not deliberately avoid, it is prone to name clashes. For example, your code may have a email.py module, since the same name, it is likely to conflict with the built-in Python standard library modules.

7, coding error details. For example, in the back if, elif, else, for, while, class, def statement forget to add ":" misuse "=" doing the equivalent comparison, use wrong indentation, it does not define variables, string and non-string connection , modify the string for a list element index position len forget to call methods and so on.

Python's syntax and other language more straightforward, rich and powerful libraries and a number of mechanisms and patterns can greatly improve development efficiency. Zero-based learning Python during the encoding must comply with its rules, attention to detail, not in accordance with the format and syntax of thinking inherent to write Python code. If you want to learn more skills to learn Python, you can choose a professional way to learn!

Guess you like

Origin www.cnblogs.com/qfzz/p/10984644.html