Python: Difference between revisions
m (Reverted edits by 81.177.14.26 (81.177.14.26); changed back to last version by Ian Bicking) |
(→Introduction: grammar) |
||
(33 intermediate revisions by 21 users not shown) | |||
Line 1: | Line 1: | ||
{{Translations}} |
|||
==Introduction== |
==Introduction== |
||
Python is a programming language. You can find out more about Python on the web[http://www.python.org/ ] or by reading the article on wikipedia [http://en.wikipedia.org/wiki/Python_%28programming_language%29]. |
|||
⚫ | |||
*The work that is being done on the user stack as part of the [[OLPC Google Summer of Code]] will be written in Python |
|||
*The main site for Python is http://www.python.org |
|||
⚫ | |||
⚫ | |||
Python is a typical interpreted language. (It tokenizes the code at program start-up. It does not JIT.) Python is thus adequately fast for simple things, but poorly suited to tasks such as number crunching. Processor intensive tasks are usually handled by a lower level language (normally C). The biggest advantage for the project is that source code is naturally supplied to the user, making Open Source software licenses easy to satisfy and making code available for children to modify. The biggest advantage for activity developers is that Python libraries are supplied which encapsulate the [[Low-level Activity API|sugar API]] |
|||
*Another package of Python that includes graphical modules including 3D is called [http://vpython.org/ Visual Python]. It is available for Windows, Mac, Linux and UNIX. |
|||
==Obtaining and learning Python== |
|||
*There is also a scientific distribution of Python called [http://www.scipy.org/Download SciPy]. This also supports Windows, Mac and Linux. |
|||
Python is commonly provided by default on Linux and BSD systems. OLPC is currently using version 2.5 on the XO. |
|||
⚫ | |||
⚫ | [http://www.pygtk.org PyGTK] is the Python interface to the GTK GUI library used in the OLPC. This library is notable for a component named Pango which simplifies the use of multiple scripts and languages. In addition, it's basic drawing library, Cairo, has some of the best support of [[SVG]] rendering which is also a major component of the OLPC. |
||
⚫ | [http://www.pygtk.org PyGTK] is the Python interface to the GTK GUI library used in the OLPC. This library is notable for a component named [http://en.wikipedia.org/wiki/Pango Pango] which simplifies the use of multiple scripts and languages. In addition, it's basic drawing library, [[Cairo]], has some of the best support of [[SVG]] rendering which is also a major component of the OLPC. |
||
The premier graphing tool for Python which puts graphing calculators to shame is [http://matplotlib.sourceforge.net/ Matplotlib]. It does support output to GTK and to [[SVG]] which are both supported on the OLPC. However, there is another Python charting app called [http://home.gna.org/pychart/ PyChart] which is probably more suitable to being stripped down (remove Postscript) into a tool for the OLPC. |
|||
==Movable Python== |
|||
Can you develop applications in Python if you only have access to shared library PCs? |
|||
In fact, yes this is possible but it does cost a small amount. For £5 (about $9.50) you can buy a Python distribution called Movable Python sometimes referred to as Python-on-a-stick because it runs from a USB stick memory device. For that matter it runs from any USB-powered storage device so it could even be installed on a 20gig Freecom drive. It can be customized by adding your own libraries so you could install GTK+, PyGTK and any other bits that you need. |
|||
I haven't personally tried to run Movable Python together with PyGTK but if your GUI is simple then you can even develop using WAX or WxPython and then have someone port it to PyGTK later when you have a working product. |
|||
==Learning Python== |
|||
The [http://www.livewires.org.uk/python/ Livewires Python Course] may be useful to create some curriculum material to teach the kids how to write their own Python applications. It would need some adaptation to fit the OLPC environment. |
The [http://www.livewires.org.uk/python/ Livewires Python Course] may be useful to create some curriculum material to teach the kids how to write their own Python applications. It would need some adaptation to fit the OLPC environment. |
||
The author of Python wrote a [http://docs.python.org/tut/ long tutorial]. |
|||
⚫ | |||
⚫ | |||
Some things to consider in Python development: |
Some things to consider in Python development: |
||
Line 32: | Line 27: | ||
* [[Python Style Guide]] |
* [[Python Style Guide]] |
||
[[Category:Software development]] |
|||
[[Category:Developers]] |
|||
[[Category:Programming language]] |
|||
[[Category:Python]] |
Latest revision as of 18:26, 16 November 2008
Introduction
Python is a programming language. You can find out more about Python on the web[1] or by reading the article on wikipedia [2].
The majority of the Sugar environment is written with the OLPC Python Environment.
Python is a typical interpreted language. (It tokenizes the code at program start-up. It does not JIT.) Python is thus adequately fast for simple things, but poorly suited to tasks such as number crunching. Processor intensive tasks are usually handled by a lower level language (normally C). The biggest advantage for the project is that source code is naturally supplied to the user, making Open Source software licenses easy to satisfy and making code available for children to modify. The biggest advantage for activity developers is that Python libraries are supplied which encapsulate the sugar API
Obtaining and learning Python
Python is commonly provided by default on Linux and BSD systems. OLPC is currently using version 2.5 on the XO.
You can download nicely packaged Python called ActivePython. They proclaim themselves as the All-in-one Python distribution for AIX, HP-UX, Linux, Mac OS X, Solaris, and Windows.
PyGTK is the Python interface to the GTK GUI library used in the OLPC. This library is notable for a component named Pango which simplifies the use of multiple scripts and languages. In addition, it's basic drawing library, Cairo, has some of the best support of SVG rendering which is also a major component of the OLPC.
The Livewires Python Course may be useful to create some curriculum material to teach the kids how to write their own Python applications. It would need some adaptation to fit the OLPC environment.
The author of Python wrote a long tutorial.
Development Advice
Some things to consider in Python development:
- PEP 8 is the Python style guide. On many issues the style guide suggests but does not require a particular style. Generally you should stick to the style guide, unless there is good reason not to. For instance, if you are interacting with a library (internal or external) that uses a different convention, don't try to translate the convention.