[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/We2one/Notes/master/python-basic-notes/python-days/Day_12.md [Back]  [Original]

## 

+ , ,

    ```python
  class F:
      def say(self):
          print("Hello F")  
  class A(F):
  	def say(self):
  		super().say()
  		print("Hello A")
  
  class B(F):
  	def say(self):
  		super().say()
  		print("Hello B")
          
  class C(A, B):
  	def say(self):
          super().say()
          print("Hello C")
          
  c = C()
  print(C.mro())
  c.say()
  # [, , , , ]
  # Hello F
  # Hello B
  # Hello A
  # Hello C
  ```


## ()

+  

    + 

        + 

            +  :  \_\_init\_\_()  self 

                ```
              def __init__(self, name):
                  """"""
                  self.name = name
              ```
              
            + **** :  **self. **  (.) 

        + 

            +  : 

                ```python
              class Article:
                  # 
                  content_max_size = 120
              ```


            +  : 
            
                ```python
              #  
              content_max_size
              #  .
              airtitle = Airtitlr()
              airtitle.content_max_size
              #  .
              Airticle.content_max_size
              ```


            +  : 
            
            +  :  **.**  (  )  ()

##  ()

+ **** :  /  / 

+ **** : ** @classmethod **  cls 

+ **** :  () ** @staticmethod **


## 

1. 

    |
    :---:|:---:
    \_\_new\_\_(cls, *args, **kwargs) | 
    \_\_init\_\_(self) | 
    \_\_del\_\_(self) | ,
    \_\_call\_\_(self) | 

2. 
   
    |
    :---:|:---:
    \_\_eq\_\_(self, other) |  ==  (self , other )
    \_\_ne\_\_(self, other) |  !=  (self , other )
    \_\_lt\_\_(self, other) |  <  (self , other )
    \_\_gt\_\_(self, other) |  >  (self , other )
    \_\_le\_\_(self, other) |  =  (self , other )
    
3. 
   
    |
    :---:|:---:
    \_\_pos\_\_(self) |  + 
    \_\_neg\_\_(self) |  - 
    \_\_invert\_\_(self) |  ~  

4. 

    |
    :---:|:---:
    \_\_add__(self, other) |  + 
    \_\_sub__(self, other) |  - 
    \_\_mul__(self, other) |  * 
    \_\_floordiv__(self, other) |  // 
    \_\_div__(self, other) |  / 
    \_\_pow__(self, other) |   ** 
    
5. 

    |
    :---:|:---:
    \_\_iadd__(self, other) | +=
    \_\_isub__(self, other) | -=
    \_\_imul__(self, other) | *=
    \_\_ifloordiv__(self, other) | //=
    \_\_idiv__(self, other) | /=
    \_\_ipow__(self, other) | **=


6. 

    |
    :---:|:---:
    \_\_int__(self) | int()
    \_\_float__(self) | float()
    
7. 

    |
    :---:|:---:
    \_\_str__(self) | 
    \_\_repr__(self) | repr__,
    \_\_doc__(self) | 
    \_\_dict__(self) | 
    
8. 

    |
    :---:|:---:
    hasattr(obj, name) | name
    setattr(obj, name, value) | namevalue
    getattr(obj, name) | name
    delattr(obj, name) | name


## 

```python
import random
import string

s= random.sample(population=string.ascii_letters + string.digits, k=6)
print(''.join(s))
```

Web Proxy Viewer  |  New URL  |  Original Page