Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
shortening python
#1
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.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
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.
Reply
#3
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.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020