[Python-Dev] Breaking undocumented API (original) (raw)

James Y Knight foom at fuhm.net
Wed Nov 10 23:21:54 CET 2010


On Nov 10, 2010, at 8:47 AM, Michael Foord wrote:

How about making this explicit (either pep 8 or our developer docs):

If a module or package defines all that authoritatively defines the public interface. Modules with all SHOULD still respect the naming conventions (leading underscore for private members) to avoid confusing users. Modules SHOULD NOT export private members in all.

I don't like the idea of the authoritative definition of a public interface being defined based on all, because that provides users almost no warning that they're using a private API: the all attribute doesn't do anything if you aren't using import *. If there was some proposal to make it so that accessing an attribute not in all did prevent or somehow warn users that they're doing something dangerous, that'd be different, but there isn't such a proposal, and I don't even know what such a proposal would look like...

On the other hand, if you make the primary mechanism to indicate privateness be a leading underscore, that's obvious to everyone.

James



More information about the Python-Dev mailing list