Getting Started with Python


Python is a clear and powerful object-oriented programming language, comparable to Perl, Ruby, Scheme, or Java.

Some of Python's notable features:

  • Uses an elegant syntax, making the programs you write easier to read.
  • Is free software in two senses. It doesn't cost anything to download or use Python, or to include it in your application. Python can also be freely modified and re-distributed because while the language is copyrighted it's available under an open-source license.
  • Runs anywhere, including Mac OS X, Windows, Linux, and Unix, with unofficial builds also available for Android and iOS.
  • Python's interactive mode makes it easy to test short snippets of code. There's also a bundled development environment called IDLE

Some Programming-language features of Python:

  • A variety of basic data types are available: numbers (floating point, complex, and unlimited-length long integers), strings (both ASCII and Unicode), lists, and dictionaries.
  • Python supports object-oriented programming with classes and multiple inheritances.
  • Data types are strongly and dynamically typed. Mixing incompatible types (e.g. attempting to add a string and a number) causes an exception to be raised, so errors are caught sooner.
  • Python's automatic memory management frees you from having to manually allocate and free memory in your code.

Writing Pythonic code is not hard---but you have to get used to the (PEP) code style rules. You can test, check, and improve your code style at online resources such as Pythonchecker.com

Getting Python


Before you start, you will need Python on your computer.

Check whether you already have an up to date version of Python installed by entering python in a command line window. If you see a response from a Python interpreter it will include a version number in its initial display. Generally any Python 3.x version will do, as Python makes every attempt to maintain backwards compatibility within major Python versions. Python 2.x and Python 3.x are intentionally not fully compatible. If python starts a Python 2.x interpreter, try entering python3 and see if an up to date version is already installed.

If you need to install Python, you may as well download the most recent stable version. This is the one with the highest number that isn't marked as an alpha or beta release. Please see the Python downloads page for the most up to date versions of Python. They are available via the yellow download buttons on that page.

Windows:

Mac:

Linux:

  • Red Hat, CentOS or Fedora: install the python3 and python3-devel packages.
  • Debian or Ubuntu: install the python3.x and python3.x-dev packages.
  • Gentoo: install the '=python-3.x*' ebuild (you may have to unmask it first).

Other Operating Systems or If installing from Source:

Learning Python


Read a tutorial and try some simple experiments with your new Python interpreter.

  • If you have never programmed before, see BeginnersGuide/NonProgrammers for a list of suitable tutorials.
  • If you have previous programming experience, consult BeginnersGuide/Programmers, which lists more advanced tutorials.
  • If English isn't your first language, you might be more comfortable with a tutorial that's been translated into your language. Consult python.org's list of Non-English resources.

Most tutorials assume that you know how to run a program on your computer. If you are using Windows and need help with this, see How do I Run a Program Under Windows. Some sites offer in-browser coding for those who want to learn Python: see Codecademy or High School Technology Services for general python and DataCampCoding Bootcamps or Dataquest for Python for data science. Print a cheat sheet of the most important Python features and post it to your office wall until you know the basics well.

Once you have read a tutorial, you can browse through Python's online documentation. It includes a tutorial that might come in handy, a Library Referencethat lists all of the modules that come standard with Python, and the Language Reference for a complete (if rather dry) explanation of Python's syntax.

When you are ready to write your first program, you will need a text editor or an IDE. If you don't want to use Thonny or something more advanced, then you can use IDLE, which is bundled with Python and supports extensions.

Need Help?


Finding help when you need it is essential to staying motivated to learn.

Take a look at BeginnersGuide/Help for mailing lists and newsgroups

Most Python books will include an introduction to the language; see IntroductoryBooks for suggested titles.

Consult BeginnersGuide/Examples for small programs and little snippets of code that can help you learn.

Or, if you prefer to learn Python through listening to a lecture, you can attend a training course or even hire a trainer to come to your company. Consult the PythonEvents page to see if any training courses are scheduled in your area and the PythonTraining page for a list of trainers.

Teachers can join the EDU-SIG, a mailing list for discussion of Python's use in teaching at any level ranging from K-12 up to university.

Complete list of Beginner's Guide Pages

Modules


Your primary resource for modules and information is the Python Package Index.

  • If you can't find anything relevant in the Package Index, try searchingpython.org- you can find anything mentioned on the Python site, in the FAQs, or in the newsgroup. More info: where to search.
  • You may also try our external guest project, pydoc.net, for advanced package and module search.
  • Next, try Google or another search engine of your choice. Searching for "python" and some relevant keywords will usually find something helpful.
  • Finally, you can try posting a query to the comp.lang.python Usenet group.