Re: Why doc call `__init__` as a method rather than function?

2023-09-18 Thread scruel tao via Python-list
Thanks for all repliers: @Tony & @Cameron, I do know related stuffs about the dunder methods, and your explanation just make it to be more clear, thank you! @Roel, you just caught everyone here, we do miss it even though we know it and use it regularly! @Clara > its both, depending on how

Why doc call `__init__` as a method rather than function?

2023-09-15 Thread scruel tao via Python-list
```python >>> class A: ... def __init__(self): ... pass ... >>> A.__init__ >>> a = A() >>> a.__init__ > ``` On many books and even the official documents, it seems that many authors prefer to call `__init__` as a "method" rather than a "function". The book PYTHON CRASH COURSE mentioned