1

C# 出身の Python 初心者です。クラスの属性とメソッドを宣伝する方法を知っています。インスタンス変数を公開したいと思います。インテリセンスにそれらを検出させることが理想的です。また、これが pythonic でない場合、または何か他のことを行う必要がある場合はお知らせください。

class MyClass(Object):
    class_attribute = "Foo"

    #This is the way I'm currently publicizing instance attributes.  
    #Basically I'm using properties instead of instance attributes.
    @property
    def instance_property(self):
        return self._instance_property

    @instance_property.setter
    def instance_property_set(self, value):
        self._instance_property = value
4

2 に答える 2