A java hobbyist programmer learning python

Aahz aahz at pythoncraft.com
Thu Jan 22 22:11:53 EST 2009


In article <7xy6x9nzwd.fsf at ruckus.brouhaha.com>,
Paul Rubin  <http://phr.cx@NOSPAM.invalid> wrote:
>Chris Rebert <clp2 at rebertia.com> writes:
>>attribution deleted by Paul Rubin:
>>>
>>> class Calculator(): ...
>>
>> Delete the 3 Java-ish accessor methods; good Python style just uses
>> the attributes directly (i.e. self.operator instead of
>> self.getOperator()).
>
>I think I would get rid of the whole Calculator class unless there
>was a good reason to keep it (i.e. you are going to have several
>Calculators active in the program simultaneously).  Just write
>straightforward imperative code without bothering with the OO stuff
>that is mandatory in Java.

IMO "good reason" is simply that using a class makes keeping track of
namespaces easier, e.g. if you add a memory capability.  I think that if
there's clearly an object that you will be manipulating, a class is
usually the right approach even if it doesn't look like it's needed.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote 
programs, then the first woodpecker that came along would destroy civilization.



More information about the Python-list mailing list