lundi 30 septembre 2019

How to get properties of object in python

class ClassB:
    def __init__(self):
        self.b = "b"
        self.__b = "__b"

    @property
    def propertyB(self):
        return "B"

I know getattr,hasattr... can access the property. But why don't have the iterattr or listattr?

Expect result of ClassB object:

{'propertyB': 'B'}

Expect result of ClassB class:

['propertyB']




Aucun commentaire:

Enregistrer un commentaire