Python language basics 1: installing Python and PyCharm

Introduction

This is the very first part of the long series of posts on the Python language. It is intended to show the basics of Python: objects, libraries, classes, methods etc. Note that I’m not a trained educator but I’ll try to be as educational as possible anyway so that even novice programmers can follow this series.

I’ve decided to learn a new technology to diversify my skills and my choice fell upon Python. It is a general-purpose language which can be used for anything ranging from simple scripting to fully-fledged Web/desktop/game etc. applications. This series is the documentation of how I’m progressing that hopefully some readers can also benefit from. I’m developing on Windows so e.g. all file paths will be described like “c:\folder\file”.

Here’s a short list of – probably biased – motivations to learn Python:

Installing Python and the PyCharm IDE

The first thing you’ll need on your computer is Python itself. Navigate to the Python download page and download the latest Python version, which is 3.4.2 at the time of writing this post. Run the installation package. If you leave the default values untouched then Python will be installed in c:\Python[xx] where ‘xx’ indicates the version, like ’34’.

You’ll notice that there’s a much earlier version available on the download page: Python 2.7.9. Python 3 was developed alongside the last versions of Python 2. This page lists some of the differences between the two. You can assume though that Python 3 is the future of Python and any new development should be undertaken with that version. I won’t go into Python 2 at all in this course.

Now that we have Python installed let’s get a an environment where can write and run Python code. In other words we need an Integrated Development Environment (IDE). One popular candidate is PyCharm by JetBrains. It comes with a paid and free edition. I’m intending to use the free version throughout. This course is meant to go over the language fundamentals without frameworks such as Django, a web framework for Python. The paid edition includes frameworks like that.

Download and install the free version of PyCharm and then open it. You will be able to select some styling options when you first run PyCharm. Select the one you like or just accept the default values, they are good enough.

Select File, New Project from the top menu. This will open the Create Project dialog. You’ll be able to enter a Location and an Interpreter. If you have several versions of Python installed you can select an earlier version if you need to adhere to it. This is similar to being able to build Java 6 or .NET3.5 applications even if you have Java 8 and .NET4.5.1 also available on your development machine.

Provide a location like “c:\PythonProjects\HelloWorld” and click “Create”. This will create an empty project folder:

PyCharm empty project

Right-click the folder and select New, Python File from the context menu. Give it any name, like “HelloPython”. This will add a file called “HelloPython.py” to your project, which also shows the default file extension of Python files.

HelloPython.py will include a reference to the author:

__author__ = 'your name'

Notice that there’s no semi-colon ‘;’ to end the statement. That’s one of the features of Python which distinguishes it from other mainstream languages like Java or C#.

Let’s run the usual Hello World program which requires only one line in Python:

print('Hello world')

This is truly a one-liner. We didn’t need to import external libraries or write a Main application entry. Select Run, Run ‘HelloPython’ from the top menu and you’ll see the message printed in the PyCharm output window:

Python hello world output

We’ll look at how to import external libraries in the next post.

Read all Python-related posts on this blog here.

Advertisement

About Andras Nemes
I'm a .NET/Java developer living and working in Stockholm, Sweden.

2 Responses to Python language basics 1: installing Python and PyCharm

  1. Yelinna says:

    A good alternative to Pycharms is https://pytools.codeplex.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: