[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



> -----Original Message-----
&gt; From: ale-bounces at ale.org [<a  rel="nofollow" href="mailto:ale-bounces";>mailto:ale-bounces</a> at ale.org] On Behalf Of
&gt; Benjamin Scherrey
&gt; Sent: Friday, January 28, 2005 11:41 AM
&gt; To: Atlanta Linux Enthusiasts
&gt; Subject: Re: [ale] Py[h]hon syntax (sic)
&gt; 
&gt; Michael,
&gt; 
&gt;     Actually python does have a mechanism, albeit a big odd, for
making
&gt; data private but it is not standard python practice to use
getter/setter
&gt; methods. Indeed, its generally poor practice in most languages but I
see
&gt; a lot of poorly written C++ &amp; Java strewn with it. There is the
&gt; occasional need for these accessors in some languages but python has
&gt; gone even further and completely eliminated their need by explicit
&gt; support for properties. Properties allows your class users to use
syntax
&gt; just like they were accessing the data members directly but actually
&gt; routes the access through methods in the class that validate,
&gt; manipulate, or generally enforce the interface to that data. Indeed,
&gt; through this method one can define read-only (and write-only!)
&gt; properties giving your data further protection. This provides for
better
&gt; enforcement of encapsulation whereas in most cases where you see
&gt; getter/setter methods, you've actually identified a violation of
&gt; encapsulation and poor design.

&lt;google_search ... read .. &gt; 

Wow, that's pretty cool.  Is there a way to do it where you don't have
to write the getter/setter?  So, if I'd like to have a variable exposed
to read and write I don't need to do anything because by default
everything is available outside the class.  But if I want a read only
member, I need to setup a reader methods and declare it.  What I'd
really like is declare a member read only, but not have to write
accessor methods unless they are needed.  I didn't see that mentioned in
any of the docs.  Did I miss it?

Thanks,

Michael



</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="01279" href="msg01279.html">[ale] Py[t]hon syntax (sic)</a></strong>
<ul><li><em>From:</em> scherrey at proteus-tech.com (Benjamin Scherrey)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg01274.html">[ale] OT Speedfactory Problems Anyone?</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg01276.html">[ale] brain damaged perl DBI</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg01266.html">[ale] Py[h]hon syntax (sic)</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg01279.html">[ale] Py[t]hon syntax (sic)</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#01275"><strong>Date</strong></a></li>
<li><a href="threads.html#01275"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>