3 ms·
A lack of freedom can be a good thing in a first language. Of course, Python doesn't always have a "right way" or they wouldn't be on their fourth command line
by fusiongyro 15y ago
A lack of freedom can be a good thing in a first language. Of course, Python doesn't always have a "right way" or they wouldn't be on their fourth command line argument parsing library. ;)
Ruby and Python will seem more similar after knowing a lot of languages. But they are different enough too. If it's not intimidating you it's probably a good second language.
- slurgfest 15y agoWhy do I keep reading about this? I don't see how any command line argument parsing library is relevant other than argparse. Do you have some concrete complaint about argparse? I am seriously wondering what I am missing, it seems so simple to me yet this seems to be a burning perennial complaint.
- gvalkov 15y agoWhy shouldn't they be relevant? Getopt is still very useful for short scripts and optparse does everything it was meant to do, even if it's not as full of features as argparse. Maybe argparse really should be the canonical choice, but I certainly wouldn't want to see the others gone. As for a minor complaint about argparse - setting up a custom help formatter [1] is not straightforward, not in the slightest in comparison to optparse [2] (which is much simpler, implementation wise). [1] http://hg.python.org/cpython/file/default/Lib/argparse.py#l144 http://hg.python.org/cpython/file/default/Lib/argparse.py#l1... [2] http://hg.python.org/cpython/file/2.7/Lib/optparse.py#l155 http://hg.python.org/cpython/file/2.7/Lib/optparse.py#l155
- fusiongyro 15y agoForgive me, I started with 1.5.2. Back then, you used getopt. Then came optparse. Then came argparse. So I guess there have only been three, unless there's a popular non-built-in option I don't know about. Now, I haven't had to maintain anything I wrote back then (not sure I ever even did use getopt) but if I'm sure if we looked we could find someone who has upgraded their option parsing twice. I'm being a little snarky. I'm really just trying to point out to the new user that the much-vaunted "TOOWTDI" concept is at best a policy decision and is to be taken with a grain of salt rather than treated like a straight-jacket. There's always more than one way to do something. Python just doesn't endorse the kind of free-for-all on every line that Perl does.