Programming Basics

  Home arrow Programming Basics arrow Exploring Python
PROGRAMMING BASICS

Exploring Python
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2011-07-06

    Table of Contents:
  • Exploring Python
  • Working with Logic

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Exploring Python


    (Page 1 of 2 )

    In this multi-part series, we will take a look at the Python programming language, specifically in terms of classes and code libraries. This article is excerpted from chapter two of the book Beginning Game Development with Python and Pygame: From Novice to Professional, written by Will McGugan (Apress; ISBN: 9781590598726).

    In the previous chapter we entered our Python code a line at a time, but now we are going to put the interactive interpreter to the side and start creating Python files. In this chapter we will cover more of the building blocks of Python code, and show you how to use classes to help with creating games. We will also explain how to use the code libraries that come with all installations of Python.

    Creating Scripts

    A file containing Python code is called a script. All you need to create scripts is a simple text editor, but it’s best to use a Python-aware editor such as SciTE (see Figure 2-1) or IDLE (which comes with the standard distribution of Python).

    Just save your script with a.pyextension, so that your operating system knows that it contains Python. To run a script, you typically just double-click it, or if you prefer the command line, typepythonfollowed by a space and the name of your script. Most Python editors will have a shortcut key to run the script you have been editing.


    Note Python allows both spaces and tabs for indentation, but it is better to use four spaces. Most Python editors will be set this way, but you may have to check it in the Options dialog of your editor.



    Figure 2-1. Editing Python code with SciTE (www.scintilla.org/SciTE.html)

    More Programming Basics Articles
    More By Apress Publishing

    blog comments powered by Disqus

    PROGRAMMING BASICS ARTICLES

    - The Transliteration Operator in Perl
    - Perl String Processing Functions
    - Perl String Processing
    - Control Flow Constructs: Loops Conclusion
    - Loop Control Constructs
    - Control Flow Constructs: the For and Foreach...
    - Loops and Control Flow Constructs
    - Expression Modifiers for Perl Control Flow C...
    - Logical Operators and Control Flow Constructs
    - Comparing Strings with Control Flow Construc...
    - Perl Operators and Control Flow Constructs
    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap