Python Tutorial - Tips
if __name__=="_main_"
# calc.py
def add(a, b):
return a + b
def mul(a, b):
return a * b
print('calc.py __name__:', __name__) # __name__ λ³μ μΆλ ₯
if __name__ == '__main__': # νλ‘κ·Έλ¨μ μμμ μΌ λλ§ μλ μ½λ μ€ν
print(add(10, 20))
print(mul(10, 20))
# cal_main.py
import calc
print('calc_main.py __name__:', __name__) # __name__ λ³μ μΆλ ₯
calc.add(50, 60)Class in Python
Instance methods
Initializer Method
Super() to inherit all the methods and properties from another class:
NP Array
Reshaping arrays
.shape

Stacking 2D data to 3D data
Documenting your code in Python (docstring)
Google format
- TypePublicInternal
Last updated