Hacker News new | past | comments | ask | show | jobs | submit login

Python is indeed an imperative language, along with the others I listed. (Your proposal would indeed be at home in a functional language like LISP.)

But I reject the idea that imperative is bad. You can compose imperative programming fine.

    def my_parser(parser):
        parser.add_argument('bar')

    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()
    my_parser(subparsers.add_parser('a'))
    my_parser(subparsers.add_parser('a2'))
> you can't have a subcommand that always collects all the remaining arguments as-is.

    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers()
    a = subparsers.add_parser('a')
    a.add_argument('args', nargs='*')
That works just fine.

    ./example a arg1 arg2 arg3

    ./example a -- arg1 --look-ma-hyphens-arg2 arg3
If you're complaining about the double hyphen syntax....that's a universal convention for UNIX-ish CLI positional arguments. Otherwise things get really murky.

    ./example a --help
Did I want help on the `a` subcommand, or did I want to pass `--help` to the `a` subcommand? The `--` syntax lets you distinguish.



> Python is indeed an imperative language, along with the others I listed.

JavaScript has functional origins, and in practice quite a bit of JavaScript is written in a functional-lite style. As a JS developer, I find it quite infuriating that Python doesn't support these patterns, as they make code a lot more readable, and it seems to be a matter of principle rather than a technical limitation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: