Eclipse and the Python plugin

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Aug 3 12:40:59 EDT 2012


On Fri, 03 Aug 2012 16:51:26 +0100, lipska the kat wrote:

> I can write a
> Python class and call it Foo and save it in a file called Bar and it's
> no big deal (at least Eclipse doesn't get excited) If I try that in Java
> the sky falls in.

:)

Correct. Python does not require, or even encourage, the one-class-per-
file rule of Java. You are encouraged to encapsulate related code into 
related units, for whatever is appropriate according to the situation. 
Whether than means one class in a module or ten will depend on the 
classes in question.

And although it was quite prevalent in the past, these days the 
convention is avoid having the module and class name to be identical, as 
in time.time, unless you really have to. Preferred is something like 
decimal.Decimal.

What I consider close to the extreme of what is comfortable in Python is 
the decimal module, which includes 19 classes and 21 module-level 
functions. It's not quite as scary as it seems -- many of those classes 
and functions are only a few lines each, and most of those are 
documentation. *Short* lines at that, this isn't Perl. The bulk of the 
module is only two classes, Decimal and Context.

Mind you, both of those are seriously large, Decimal has 117 methods and 
Context around 70-80 (I stopped counting). So as I said, that's about the 
upper limit for what I consider reasonable in a single module.



-- 
Steven



More information about the Python-list mailing list