Python 2.2 for FREESCO 027

What is Python?

python 1), (Gr. Myth. An enormous serpent that lurked in the cave of Mount Parnassus and was slain by Apollo)

  1. any of a genus of large, non-poisonous snakes of Asia, Africa and Australia that suffocate their prey to death.
  2. popularly, any large snake that crushes its prey.
  3. totally awesome, bitchin' language that will someday crush the $'s out of certain other so-called VHLL's ;-)

Python is an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java.

Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, as well as to various windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface.

The Python implementation is portable: it runs on many brands of UNIX, on Windows, DOS, OS/2, Mac, Amiga… If your favorite system isn't listed here, it may still be supported, if there's a C compiler for it. Ask around on comp.lang.python – or just try compiling Python yourself. Already done for FREESCO by yours truly ;-)

Python is copyrighted but freely usable and distributable, even for commercial use.

Requirements

  • lewy-lib package
  • utils-1 package
  • aprox. 52 Mb (!) free hard disk space
  • recommended for Pentium class FREESCO machines only

Sample Installation

    [Linux] installpkg http://dingetje.homeip.net/packages/python
    Now downloading the install script for python...
    Warning: installing software from a 3rd party package could damage your
    router's configuration or make it insecure. You should only install a
    package from an author/site you trust.
    http://dingetje.homeip.net//packages/python.sh (1K)
    python.sh [########################] 1K | 1479.92K/s
    1911 bytes transferred in 0.00 sec (666.97k/sec)
    Do you want to view the install script before executing it [y/n]? n
    Continue installing [y/n]? y
     _____       _   _                   ___    ___
    |  __ \     | | | |                 |__ \  |__ \
    | |__) |   _| |_| |__   ___  _ __      ) |    ) |
    |  ___/ | | | __| '_ \ / _ \| '_ \    / /    / /
    | |   | |_| | |_| | | | (_) | | | |  / /_ _ / /_
    |_|    \__, |\__|_| |_|\___/|_| |_| |____(_)____|
            __/ |
           |___/

    Python 2.2 installation, last edit Apr, 5th, 2002
    Downloading...please be patient, this package is 12.5 Mb....!!
    http://dingetje.homeip.net/packages/python.tgz (12276K)
    python.tgz [########################] 12276K | 1025.63K/s
    12571551 bytes transferred in 12.00 sec (1023.35k/sec)
    Unpacking...please be patient, this is a big package....
    Do you want to keep a copy of the package in your /www directory [y/n] ? y
    Starting python package... Done

    Installation is complete.
    Now you can use - python

    Make sure to checkout http://www.python.org and the samples
    in /mnt/router/packages/python/Python2.2, enjoy ;-)
    [Linux]

Note: because of the size of the package, please use your nearest FREESCOSoft mirror to install this package.

Sample run

    [Linux] python
    Python 2.2 (#2, Feb 16 2002, 01:27:31)
    [GCC 2.7.2.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

You are running python now in interactive mode. Type 1+1 and python will respond with the correct answer, euh…..2!2).

You can simply run existing python programs (usually with the extension .py) as follows:

python filename.py

The packages comes with library modules in /mnt/router/packages/python/lib, I also recommend to look at the /mnt/router/packages/python/Python-2.2/Demo directory for python sample code.

[Linux] cd /mnt/router/packages/python/Python-2.2/Demo
[Linux] cd curses
[Linux] python rain.py

WARNING: It will start raining on your console after running the above mentioned demo script! Type q to quit.

To make a script execute automatically use the following syntax:

#!/usr/bin/env python
print "hello world"

Save this in a file called hello.py, then do:

chmod +x hello.py

When you type hello.py this mind boggling python program will print “hello world” on your display. Isn't it amazing what technology can do, where will it end? ;-)

Links

Check out the links below for some good tutorials for the python programming language.

dingetje 2005/04/16 23:29

1) This section is blatantly copied from http://www.python.org
2) I'm almost certain
 
freesco/howtos/python.txt (58876 views) · Last modified: 2005/09/14 00:49 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki