New users think it is simple, but it is actually not as simple as C. What are the knowledge, habits, and details of beginners and veterans? Thank you! New users think it is simple, but it is actually not as simple as C. What are the knowledge, habits, and details of beginners and veterans? Thank you! Reply content: the predecessors asked:
Hidden features of Python
Excerpt directory:
- Argument Unpacking
- Braces
- Chaining Comparison Operators
- Decorators
- Default Argument Gotchas/Dangers of Mutable Default arguments
- Descriptors
- Dictionary default. get value
- Docstring Tests
- Ellipsis Slicing Syntax
- Enumeration
- For/else
- Function as iter () argument
- Generator expressions
- Import this
- In Place Value Swapping
- List stepping
- _ Missing _ items
- Multi-line Regex
- Named string formatting
- Nested list/generator comprehensions
- New types at runtime
- . Pth files
- ROT13 Encoding
- Regex Debugging
- Sending to Generators
- Tab Completion in Interactive Interpreter
- Ternary Expression
- Try/retry t/else
- Unpacking + print () function
- With statement
There is also a black magic Meta class:
Http://blog.jobbole.com/21351/.
Original article: http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python
Measure the test taker's knowledge about the data structure implementation of the built-in list/dict/set containers and the time complexity of some basic operations. This is not difficult. The python list is actually a vector, not a linked list, And dict/set is a hash table .. Then avoid frequent errors such as insert/delete in the list.
This also makes python not suitable for functional programming. It is a trivial matter to say that lambda cannot cross-row, but there is no persistent list/search tree in the standard library .. It is not feasible to implement it by yourself. CPython function calls are costly.
So let's write the loop and throw an exception honestly. When in Rome, do as the Romans do. A few keywords:
Decorator
Yield (generator)
Descriptor
Method & function
Slot
MRO
Introspection (id, type, dir, vars, etc)
Then there are various common modules, such as itertools, functools, collections, and copy.
If you are interested, read the Python source code analysis written by Chen Ru. You can learn about the small integer cache, int, list, dict cache pool, and string intern mechanism, memory Management and other internal implementations. A small version of a major branch is walled into an iterator, generator, and iteratable object. After figuring out these concepts, the interviewer will feel that you are awesome. Method Resolution Order (MRO) is the most interesting value for the division of positive and negative numbers ).
MRO refers to the search order of method or attribute in class inheritance. The simplest case is the inheritance tree of classic class. In this case, the search order is depth first, from left to right.
For example:
Class ():
Pass
Class B ():
Pass
Class C ():
Pass
Class D (B, C ):
Pass
In the above inheritance tree, the MRO of class D should be D, B, A, C. It is worth noting that A is located in front of C.
For new style class, python 2.2 and 2.3 (or above) are also different. MRO algorithm after 2.3 is called C3 algorithm. For details, You can google it. I personally think it is very interesting. After learning the basic Python syntax, you can learn other languages to see if some of their features can be implemented in Python.
Let me give you a small example.
In Racket, there is a stream structure.
(define ones (lambda () (cons 1 ones)))
A very important built-in function: type. Talks | Armin Ronacher's Thoughts and Writings
There is a pdf here. Let me take a look.
Or the webpage A Curious Course on Coroutines and Concurrency
It should be that yield of Python is used very well.
Example: