[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-date: Fri Jan 28 14:40:12 2005 -->
- <!--x-from-r13: zuvefpu ng ahoevqtrf.pbz ([vpunry Vvefpu) -->
- <!--x-message-id: [email protected] -->
- <!--x-subject: [ale] Py[h]hon syntax (sic) -->
- <li><em>date</em>: Fri Jan 28 14:40:12 2005</li>
- <li><em>from</em>: mhirsch at nubridges.com (Michael Hirsch)</li>
- <li><em>subject</em>: [ale] Py[h]hon syntax (sic)</li>
> -----Original Message-----
> From: ale-bounces at ale.org [<a rel="nofollow" href="mailto:ale-bounces">mailto:ale-bounces</a> at ale.org] On Behalf Of
> Benjamin Scherrey
> Sent: Friday, January 28, 2005 11:41 AM
> To: Atlanta Linux Enthusiasts
> Subject: Re: [ale] Py[h]hon syntax (sic)
>
> Michael,
>
> Actually python does have a mechanism, albeit a big odd, for
making
> data private but it is not standard python practice to use
getter/setter
> methods. Indeed, its generally poor practice in most languages but I
see
> a lot of poorly written C++ & Java strewn with it. There is the
> occasional need for these accessors in some languages but python has
> gone even further and completely eliminated their need by explicit
> support for properties. Properties allows your class users to use
syntax
> just like they were accessing the data members directly but actually
> routes the access through methods in the class that validate,
> manipulate, or generally enforce the interface to that data. Indeed,
> through this method one can define read-only (and write-only!)
> properties giving your data further protection. This provides for
better
> enforcement of encapsulation whereas in most cases where you see
> getter/setter methods, you've actually identified a violation of
> encapsulation and poor design.
<google_search ... read .. >
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>