Hi guys!<br><br>I'm noob in python and I would know how to correctly use the property. I have read some things about it but I do not quite understand.<br><br>I found this:<br><br><pre class="default prettyprint"><code><span class="kwd">class</span><span class="pln"> C</span><span class="pun">(</span><span class="kwd">object</span><span class="pun">):</span><span class="pln"><br>
    </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">):</span><span class="pln"><br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_x </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br>
<br>    </span><span class="lit">@property</span><span class="pln"><br>    </span><span class="kwd">def</span><span class="pln"> x</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">):</span><span class="pln"><br>
        </span><span class="str">"""I'm the 'x' property."""</span><span class="pln"><br>        </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_x<br>
<br>    </span><span class="lit">@x</span><span class="pun">.</span><span class="pln">setter<br>    </span><span class="kwd">def</span><span class="pln"> x</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln"> value</span><span class="pun">):</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_x </span><span class="pun">=</span><span class="pln"> value<br><br>    </span><span class="lit">@x</span><span class="pun">.</span><span class="pln">deleter<br>
    </span><span class="kwd">def</span><span class="pln"> x</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">):</span><span class="pln"><br>        </span><span class="kwd">del</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">_x<br>
<br></span></code><span id="result_box" class="" lang="en"><span class="hps">But</span> <span class="hps">I think it's</span> <span class="hps">a bad habit</span> <span class="hps">to use</span> <span class="hps">_</span> <span class="hps">to change the visibility</span> <span class="hps">of the attributes</span> <span class="hps"></span><span class="hps">as in</span> <span class="hps">JAVA.<br>
<br></span></span><span id="result_box" class="short_text" lang="en"><span class="hps">How to correctly use</span> <span class="hps">the property</span><span class="">?</span></span><br></pre><br>