Why does python use two underscores for certain things?

前端 未结 7 1385
滥情空心
滥情空心 2020-11-27 15:43

I\'m fairly new to actual programming languages, and Python is my first one. I know my way around Linux a bit, enough to get a summer job with it (I\'m still in high school)

7条回答
  •  攒了一身酷
    2020-11-27 16:09

    They are used to specify that the Python interpreter should use them in specific situations.

    E.g., the __add__ function allows the + operator to work for custom classes. Otherwise you will get some sort of not defined error when attempting to add.

提交回复
热议问题