Review Python fundmentals after 3 years
Hi, after many years I still find Python an attractive programming language even after I have worked as a Java engineer for pass three years.
It has plenty of modern features compared to Java language, and most importantly, many startups use Python or Go for their systems. So I’ve decided that it’s time for me to learn Python again.
Data Structure
int&string
- Immutable data type.
1
2i = 0
s = "123"
list
- Mutable data type. Use index to search element
1
party = [1,2,3]
tuple
- Immutable data type. often used in *args
- unchange list
1
party = (1,2,3)
set
- distinct element.
1
set([1,2,3,4,5,1,2,3,4,5])
dict
- map structured data type.
1
member_score = {"John":98,"Helen":78}
using Function
1 | |
Python lambda
1 | |
Deque
1 | |
Matrix transpose in Python
1 | |
Techique of for loop
1 | |
Other concept
- Use
json.dumps(x)to serialize the object into json string - Use
json.loads(x)to deserialize the jsonstring into specific object - When python interpreter boots, namespace will be created an never be deleted
namespaceis a space that python can store the variable, so even variable which has same name may stored in many space based on their scope.- python is no
private, convently we use__argumentas a private attribute and avoid accidently override by subclass or something else._ageuse int protect attribute. - To increase the loading speed of the python module, python store their compile version into
__pycache__and namedmodule.version.pyc
Use inerator
1 | |
Use generator
1 | |
Unit Test
1 | |
Multi-thread
1 | |
Python GIL
//TODO
Review Python fundmentals after 3 years
https://clark1945.github.io/2025/09/11/Review-Python-fundmentals-after-3-years/