
Joao S. O. Bueno writes:
Anyway - back to the thread - it does not seen a bad idea for me at all.
I think it's a waste of time: an invitation to endless bikeshedding and a slippery slope to very half-baked attempts at full-featured utilities in the module's "__main__" section. It won't be consistent, as many modules already have test code in there, although I suppose you could move that functionality to a "test" command (at the expense of breaking existing "install and test" scripts). Finally to the extent that the feature itself is pretty consistently present, people are going to demand that their favorite options be one-linable, and that pretty much every module grow one-line-abilty. Whatever happened to "not every 3-liner need be builtin"? The suggested scripts also seem, uh, of incredibly marginal usefulness. Except for calendar, but there, the desirable set of options is huge (did you know that many Japanese like their weeks to start with Monday, for example? and that some people care about the Mayan calendar? or of more relevance, different base years -- in Japan it's Year 28 of the Heisei Emperor). Alexander was right as to the ultimate goal (full implementations of POSIX date or GNU calendar plus whatever extensions might seem useful). But if you do more than one or two of those, you're going to end up with a confusing mishmash of CLI syntaxes, with a long script invocation: "python -m calendar ...". That said, your earlier idea taken one step farther seems like the best way to go: create a module oneline[1], put the functionality in there, put it on PyPI, and you can start lobbying for stdlib inclusion in 2018. Or better yet, create a pysh script[2] so you can omit the "-m". An advantage to this is that you can create an API, a module-level variable such as "one_line_subcommands", which would contain a dict of name-function pairs that pysh could look for and run. You could also have a global directory in pysh so that pysh can override those stubborn module maintainers who won't add your favorite one-liner to __main__. The best idea of all, perhaps, is # echo >> /etc/shells /usr/bin/python # chsh -s /usr/bin/python <your login> (Sorry, Windows users, I don't know the equivalent there.) Or make that ipython for even more shellshocking convenience. Footnotes: [1] Too bad it can't be called "1line". "oneln" is a little shorter. [2] ISTR that name is already taken but can't think of a better one. "py1line" maybe?