1.6 First steps with Python

Working in the console

It is always possible to use the Python console, to execute line-by-line instructions. To do it you need to open a MS-DOS (Windows) or terminal (Linux) window, write “python” and type Enter. Then the Python console appears:


Creating scripts

In practice you will not use the console for operations involving more than 2-3 lines of codes. Rather, you will use Python scripts. Python scripts can be created with any text editor (e.g. Notepad). For instance, you can create a file called “test.py”. The ”.py” extension is needed for the script to be able to run. Just copy-paste the following lines in some text editor, and save the file:

# -*- coding: utf-8 -*-
print 2+2
raw_input("Press Enter to close")

To execute the script, all you have to do is double-click on the file icon in the Explorer window or on the Desktop ! You should get the following window:


Python scripts using AsPyLib

To use the whole AsPyLib package in a Python script, you need to add the following statement:

import aspylib

If you only need one or two modules, then it’s not needed to load the whole package and you can use:

from aspylib import astro, calib

Then all functions are available in the form astro.function() or calib.function()


There are plenty of tutorials and forums about Python on the web. These pages are especially interesting:

Table Of Contents

Previous topic

1.5 More about Python installation (Windows)

Next topic

2. Download

This Page