Book Image

Sage Beginner's Guide

By : Craig Finch
1 (1)
Book Image

Sage Beginner's Guide

1 (1)
By: Craig Finch

Overview of this book

Table of Contents (17 chapters)
Sage Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – creating a combat simulation package


Create a directory called combatsim. The name of the directory is the name of the package, so it should follow the Python naming conventions for packages. The name should use lower-case letters and should be as short as possible, in case someone wants to use your package on a system that doesn't support long names. Underscores are officially discouraged in package names, but don't be afraid to use them if it makes the package name easier to understand. Now, create a new file in the directory called __init__.py. Leave this file empty. It only needs to be present to tell the Python interpreter that this directory is a package.

In the directory combatsim, enter the following code in a file called components.py. Essentially, we're just going to cut and paste to place the definitions for the Cannon, Track, and Turret classes into their own files. We will repeat the process with the definitions of the classes Ground_Vehicle and Tank.

class Cannon...