[issue41592] Make _SubParsersAction public

paul j3 report at bugs.python.org
Mon Oct 25 19:51:03 EDT 2021


paul j3 <ajipanca at gmail.com> added the comment:

A _SubParsersAction is private to the extent that users should not attempt to create it directly, and thus don't need to know the details - beyond what's documented:

"The add_subparsers() method is normally called with no arguments and returns a special action object. This object has a single method, add_parser(), which takes a command name and any ArgumentParser constructor arguments, and returns an ArgumentParser object that can be modified as usual."

All action objects have methods like __call__ and format_usage. The subparsers Action has other methods, but add_parser is the only new "public" method.

There's a tension in writing documentation between getting all details just right, and providing just enough for most users.  As it is, many new users are over whelmed by the documentation.

My understanding is that the "private/public" designation is a convenience for users, and not enforced by Python developers.  

I gather though that some corporate users have policies that prohibit modification of "private" objects, supposedly due to a fear that Python could modify or eliminate those objects without proper notification.  Somehow the "public" documentation sets that part of the code in stone.  My experience here is that it's easier modify the documentation to fit the code than the other way around :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41592>
_______________________________________


More information about the Python-bugs-list mailing list