Frequently used built-in modules.
Containing some common data structure & algorithm implemented with built-in functionality/code/lib. Frequently used in leetcode practice.
-
use iterator to save memory.
-
itertools: permuation, combination, product. realpython blog -
formatting string with
f-string. -
operators: call basic operators as functions. -
common data structures
listcollections.deque: queue, deque, stackheapq: default is min heapset: hash setdict: hash mapunion find, code example, time complexity note
- For parsing command line arguments, use arg_parser.py
- references:
My notes
- high-order function: a function that returns a function.
- decorator: a function that takes a function input, calls this function in an created inner(wrapper) function and returns the inner function, or directly return the function.
- When we want a decorator to receive arguments, we define it as a fuction that returns a decorator function.
- decorators could also be callble objects. This has similarity with React Components where we have function component and class component. python decorator could be a callable class, so it could store states.
- how we fix the definition: decorator: a
functioncallable object that takes a function input, calls this function in an created inner function and returns the inner function, or directly return the function.
- references:
- RealPython blog1, blog2
- Common use cases: stackoverflow, some wiki
My templates for drawing plots with matplotlib.
RealPython blog
python -m unittest discover -s tests
things we should avoid.