Python Forum
shortening python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Forum & Off Topic (https://python-forum.io/forum-23.html)
+--- Forum: Bar (https://python-forum.io/forum-27.html)
+--- Thread: shortening python (/thread-711.html)



shortening python - Skaperen - Oct-31-2016

i run Ubuntu Linux and have added symlinks so i can invoke python and python3 with just py and py3.  this is what i have in /usr/local/bin:

Output:
lrwxrwxrwx 1 root root   16 Oct  9 02:08 /usr/local/bin/py -> ../../bin/python lrwxrwxrwx 1 root root   17 Oct  9 02:08 /usr/local/bin/py2 -> ../../bin/python2 lrwxrwxrwx 1 root root   17 Oct  9 02:08 /usr/local/bin/py3 -> ../../bin/python3
has anyone else done the same or similar.

i have also added python support to the bash function that handles missing commands.  if a command name cannot be found it looks in the current directory for ${name}.py and if that is not found then it looks there for ${name}.py3.  if found, it runs them via the appropriate python interpreter.  this lets me try out new code with less typing.  this is not set up for root.  i still run bash for my interactive shell.


RE: shortening python - casevh - Nov-01-2016

I do the the same thing but for versions of Python that I compile myself. I currently have py27, py33, py34, py35, and py36 symlinks active.


RE: shortening python - Ofnuts - Nov-01-2016

I would have used aliases for that instead of setting up links.

IMHO with command completion, shortening commands isn't so useful. And when I write python code, I use a shebang so the code itself remembers if it runs needs python2 or python3, and I don't even need to call "pythonXX" explcitly.