fix plot style breakage
[PyX/mjg.git] / faq / python.rst
blob03ee672b6e5f4d7335dce67db1371ba98ff7052d
1 ======
2 Python
3 ======
5 .. what_is_python:
7 What is Python?
8 ===============
10 From `www.python.org <http://www.python.org>`_:
12    Python is an *interpreted, interactive, object-oriented* programming
13    language. It is often compared to Tcl, Perl, Scheme or Java.
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.
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**.
31 Where can I learn more about Python?
32 ====================================
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.
37 What do I need to import in order to use PyX?
38 =============================================
40 It is recommended to begin your Python code with::
42    from pyx import *
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``.
50 For convenience, you might import specific objects of a module like in::
52    from graph import graphxy
54 which allows you to write ``graphxy()`` instead of ``graph.graphxy()``.
56 All code segments in this document assume that the import line mentioned in the
57 first code snippet is present.
59 What is a raw string and why should I know about it when using PyX?
60 ===================================================================
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::
68    c.text(0, 0, r"$\alpha\beta\gamma$")