accessing class data members
Curtis Jensen
cjensen at bioeng.ucsd.edu
Tue Jul 3 13:59:32 EDT 2001
In many OO languages, and theory, it is often the case that when you
want to know the value of some data member, that a function is written
to return that value. However, in Python it seems that people just
access the data member directly.
for example:
if there were a class that represented a physical object. In the class
there were data members that held the objects temperature and location.
If I wanted to know the temperature of an object, I could just use
obj.temperature. Though in other languages, the convention seems to
call a function that returns the value, like: obj.get_temperature.
Which is better?
--
Curtis Jensen
cjensen at bioeng.ucsd.edu
http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451
More information about the Python-list
mailing list