Python is Python3

Python is Python3

Table of Contents

    If you are using Python on Ubuntu, chances are it is Python3. And if so, it can be really annoying to have to bang that 3 on the end. Wouldn’t it be great if you could just call Python and know that you are actually getting Python3 by default? Well, the good news is, you can!

    There is a great little Ubuntu package called python-is-python3 and when you install it you are using python3.

    To install the package on Ubuntu, open a terminal window and type:

    sudo apt update
    sudo apt install python-is-python3
    

    Within seconds you will have it installed. Then in your terminal type:

    python --version
    

    The version of python you are using will display in the terminal.

    No more pesky 3 on the end. Just good old python all the way!

    And another quick tip. If you want to test out some python code in the terminal. Run python in the terminal! It’s easy. Simply open your terminal and type python

    python
    

    You should see something like this:

    Type in your python commands the usual way. You can use variables, define functions, etc. Just like you would in a normal editor (though you wouldn’t use it as such, testing only really)

    Here’s something I threw in there to show you how it works.

    Using Python this way is also a great way to learn the language. Play around with variables, write some simple functions, print some statements out… in fact anything you can do in an editor, you can do in the terminal really. Just remember, nothing is saved though!

    When you’ve finished, just hit the Ctrl-D key and it will exit Python and return you to the command prompt.

    Hope you found this tip useful.

    Published: 3 weeks, 5 days ago.

    Related Posts

    Coding an RSI Indicator in Python

    In this latest addition to my portfolio, I’ve developed an RSI (Relative Strength Index) Indicator …