On Jun 22, 2016 7:54 PM, "Barry Warsaw" <ba...@debian.org> wrote:
>
> On Jun 22, 2016, at 11:25 AM, Ben Finney wrote:
>
> >This seems to be more common now that command-line invocation is
> >becoming even more discouraged. When the upstream documentation
> >recommends ‘python3 -m foo.bar’ as the primary means of invoking the
> >command line functionality, that really blurs the line between
> >command-line application versus library.
>
> Indeed.  It's true that -m invocation isn't as pretty as a /usr/bin
script,
> but it does have the advantage of unambiguously choosing the Python
version
> you want to run the script with.  How important that is depends on the
> application of course.
>
> >There is a compounding tendency to disparage ‘python3 ./foo/bar.py’,
> >which is subject to weird hacks and incomplete workarounds like
> ><URL:https://www.python.org/dev/peps/pep-0366/>. I wish this trend could
> >be effectively reversed, because IMO this is a serious impediment to
> >considering Python a good choice for command-line scripting. But this is
> >all a digression, my apologies.
>
> Sorry, I don't quite understand the above.  Do you mean that you would
rather
> use `python3 ./foo/bar.py` more often and `python3 -m foo.bar` less often?
>
> In any case, thanks Hugo for choosing Python 3 as the version to use for
the
> /usr/bin script. :)

Speaking with my application developer hat on, the latter invocation
ideally helps the user be more aware of what version of Python they're
using.

This is beneficial in a couple cases:

- pip installing something: it's important for the user to know which
version of Python they're using

- running flake8 against a codebase. Flake8 relies on the version of
Python's AST for certain things. If the user is writing code with async
keywords but running Flake8 on Python 2.7, then they'll be in for a world
of unpleasantness.

By extension the same logic applies to any application that supports
multiple versions of Python but depends on things like the stdlib AST
module.

It's certainly a hideous invocation, but it has it's benefits.

Cheers,
Ian

Reply via email to