Creating a Terminal Program with Python

On a *nix system (linux/unix), if you: $ chmod 0744 your_file.py -rwxr–r– your_file.py and add the path to python as the first line of your_file.py: #!/usr/bin/python or (in my case): #!/usr/local/bin/python Once you do that, instead of running it like this: $ python your_file.py You can run it like this: $ ./your_file.py or even rename … Read more

How to download python from command-line? [closed]

wget –no-check-certificate https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz tar -xzf Python-2.7.11.tgz cd Python-2.7.11 Now read the README file to figure out how to install, or do the following with no guarantees from me that it will be exactly what you need. ./configure make sudo make install For Python 3.5 use the following download address: http://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz For other versions and the … Read more

Rename JPG files according to date created

jhead -n DSCN0382.JPG DSCN0382.JPG –> 0408-150734.jpg any strftime argument can be given as well: jhead -n%Y%m%d-%H%M%S *.jpg This will rename files matched by *.jpg in the format YYYYMMDD-HHMMSS jhead -n%Y%m%d-%H%M%S DSCN0382.JPG DSCN0382.JPG –> 20120408-150734.jpg see also the man page for lots of other cool options. You can for instance correct (shift) the EXIF date. This … Read more

How can I launch ipython from shell, by running ‘python …’?

To start IPython shell directly in Python: from IPython import embed a = “I will be accessible in IPython shell!” embed() Or, to simply run it from command line: $ python -c “from IPython import embed; embed()” embed will use all local variables inside shell. If you want to provide custom locals (variables accessible in … Read more