~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to faq/python.rst

  • Committer: Package Import Robot
  • Author(s): Stuart Prescott
  • Date: 2012-12-17 13:45:12 UTC
  • mfrom: (1.1.4)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: package-import@ubuntu.com-20121217134512-u0w6lrgdowsc1sfu
Tags: 0.12.1-1
* New upstream release
* Update maintainer address.
* Update copyright format URL.
* Bump standards version to 3.9.4 (no changes required).
* Drop postinst that was needed for lenny->squeeze upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
======
 
2
Python
 
3
======
 
4
 
 
5
.. what_is_python:
 
6
 
 
7
What is Python?
 
8
===============
 
9
 
 
10
From `www.python.org <http://www.python.org>`_:
 
11
 
 
12
   Python is an *interpreted, interactive, object-oriented* programming
 
13
   language. It is often compared to Tcl, Perl, Scheme or Java.
 
14
 
 
15
   Python combines remarkable power with very clear syntax. It has modules,
 
16
   classes, exceptions, very high level dynamic data types, and dynamic typing.
 
17
   There are interfaces to many system calls and libraries, as well as to various
 
18
   windowing systems (X11, Motif, Tk, Mac, MFC). New built-in modules are easily
 
19
   written in C or C++. Python is also usable as an extension language for
 
20
   applications that need a programmable interface.
 
21
 
 
22
   The Python implementation is portable: it runs on many brands of UNIX, on 
 
23
   Windows, OS/2, Mac, Amiga, and many other platforms. If your favorite system 
 
24
   isn't listed here, it may still be supported, if there's a C compiler for it. 
 
25
   Ask around on `comp.lang.python <news:comp.lang.python>`_ – or just 
 
26
   try compiling Python yourself.
 
27
  
 
28
   The Python implementation is `copyrighted <http://www.python.org/doc/Copyright.html>`_
 
29
   but **freely usable and distributable, even for commercial use**.
 
30
 
 
31
Where can I learn more about Python?
 
32
====================================
 
33
 
 
34
The place to start is `www.python.org <http://www.python.org>`_ where you will
 
35
find plenty of information on Python including tutorials.
 
36
 
 
37
What do I need to import in order to use PyX?
 
38
=============================================
 
39
 
 
40
It is recommended to begin your Python code with::
 
41
 
 
42
   from pyx import *
 
43
 
 
44
when using PyX. This allows you for example to write simply ``graph.graphxy``
 
45
instead of ``pyx.graph.graphxy``. The following modules will be loaded:
 
46
``attr``, ``box``, ``bitmap``, ``canvas``, ``color``, ``connector``, ``deco``,
 
47
``deformer``, ``document``, ``epsfile``, ``graph``, ``path``, ``pattern``,
 
48
``style``, ``trafo``,  ``text``, and ``unit``.
 
49
 
 
50
For convenience, you might import specific objects of a module like in::
 
51
 
 
52
   from graph import graphxy
 
53
 
 
54
which allows you to write ``graphxy()`` instead of ``graph.graphxy()``.
 
55
 
 
56
All code segments in this document assume that the import line mentioned in the
 
57
first code snippet is present.
 
58
 
 
59
What is a raw string and why should I know about it when using PyX?
 
60
===================================================================
 
61
 
 
62
The backslash serves in standard Python strings to start an escape sequence.
 
63
For example ``\n`` corresponds to a newline character. On the other hand, TeX
 
64
and LaTeX, which do the typesetting in PyX, use the backslash to indicate the
 
65
start of a command. In order to avoid the standard interpretation, the string
 
66
should be marked as a raw string by prepending it by an ``r`` like in::
 
67
 
 
68
   c.text(0, 0, r"$\alpha\beta\gamma$")