summaryrefslogtreecommitdiff
path: root/oop/MethodTest.py
blob: 67fdf57e445180cb08875c751a23cdf8cb98be9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

from datetime import datetime

class Test:
    alias = 'wudaokou nash'

    @staticmethod
    def static_mode(language):
        print(f'static method, {Test.alias} codes in {language}')

    @classmethod
    def class_mode(cls, language):
        print(f'class method, {cls.alias} codes in {language}')


class Repr:

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return f'{self.__class__.__module__}.{self.__class__.__qualname__}(name={self.name})'

    def __str__(self):
        return f'{self.name}'


if __name__ == '__main__':
    t = Test()
    t.static_mode('chinese')
    t.class_mode('english')

    r = Repr('zhang')
    print(r)
    print(repr(r))
    print(str(r))

    now = datetime.now()
    print(now.__str__())
    print(now.__repr__())