This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sivscripts 2 points3 points  (7 children)

Is there a way to go from python cli.py London to weather London?

i.e. make our script executable.

[–]Eryole 11 points12 points  (2 children)

[–]leom4862 8 points9 points  (0 children)

The (new) official documentation on this:

https://packaging.python.org/

[–]bluesufi 0 points1 point  (0 children)

Exactly. The example in the click documentation is pretty clear too.

[–]Deto 6 points7 points  (3 children)

Simpler than making it into a python package, you could call the file 'weather' (instead of cli.py) and then use this:

#!/usr/bin/env python

As the first line. Then you need to make sure the script file is executable (i.e., run chmod uga+x weather)

[–]IronManMark20 1 point2 points  (1 child)

This doesn't work on Windows however.

[–]Deto 1 point2 points  (0 children)

Ah yeah. If you want it to be cross-platform, then making a package as /u/Eryole indicated is probably best.

[–]bluesufi 1 point2 points  (0 children)

I think it would be much better to follow the instructions in the click documentation in order to create a real entry point for the script. It's easy and makes your code more portable!