With or without leading underscore...
steven at REMOVE.THIS.cybersource.com.au
Tue Aug 11 05:29:20 CEST 2009
On Mon, 10 Aug 2009 16:37:25 +0200, Ulrich Eckhardt wrote:
> ...that is the question!
> I have a module which exports a type. It also exports a function that
> returns instances of that type. Now, the reason for my question is that
> while users will directly use instances of the type, they will not
> create instances of the type themselves.
> So, the type is a part of the public API, but its constructor is not.
> Should I mark the type as private (with a leading underscore) or not?
My opinion is that if you have to ask the question "Should this class be
private?", then the answer is No.
Only make objects private if you have specific reasons for doing so. I
know this goes against the advice given by other languages (namely, make
everything private unless you need it to be public) but Python encourages
openness and transparency.
More information about the Python-list