Quick actions

cmd+k|ctrl+k

Navigation

Languages

method_type

Snippet info

Language

Python

Visibility

public

Author

mori

Created

2019-05-03T01:29:37Z

Updated

2019-05-03T01:29:51Z

class ClassType:
    type = "default"

    def __init__(self):
        self.show = self.type

    def instance_method(self):
        self.show = "instance"
        
    @classmethod
    def class_method(cls):
        return cls()

    @staticmethod
    def static_method():
        return ClassType()

    def print_type(self):
        print(self.show)


class InheritedClassType(ClassType):
    type = "inherited"

a = InheritedClassType.static_method()
b = InheritedClassType.class_method()
c = ClassType()
d = InheritedClassType()

a.print_type()
b.print_type()

c.print_type()
c.instance_method()
c.print_type()

d.print_type()
d.instance_method()
d.print_type()

    
INFO