Home  >  Article  >  Backend Development  >  Python class private method

Python class private method

巴扎黑
巴扎黑Original
2016-12-09 09:15:261456browse

Class private method

__private_method starts with two underscores, declaring that the method is a private method and cannot be called outside the class.

Call slef.__private_methods inside the class.

Proprietary methods of class:

__init__ constructor, call

__del__ destructor when generating an object, use

__repr__ to print and convert

__setitem__ to assign according to index

__getitem__ to obtain according to index Value

__len__ gets length

__cmp__ comparison operation

__call__ function call

__add__ addition operation

__sub__ subtraction operation

__mul__ multiplication operation

__div__ division operation

__mod__ remainder operation

__pow__ weighing square


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn