2. Quick Introduction

This chapter introduces the basic principles behind faces . To understand this chapter you should have a minimal understanding of programming languages. If this is not the case, you should definitely read the python tutorial first. For the others here is a short summary of the programming constructs in this chapter:
strings literals
are enclosed in single or double quotes
"This is a string"
'This is also a string'

comments
are started with a # sign and end at the next line
# This is a comment

variables
are assigned with the "=" sign:
the_world_is_flat = 0

functions
are defined with the def keyword:
def my_add(arg1, arg2):
    return arg1 + arg2
As you can see the function body is indented below the function header. Indentation is python's way of grouping statements. To call the function you write:

sum_of_1_and_2 = my_add(1, 2)

classes
are declared with the class keyword:
class the_new_class(base_class):
    class_attrib = 1
the_new_class inherits all attributes and methods of base_class. Classes are often used in faces to define resource, reports, and charts.

modules
are a collection of python objects (function, variables, classes). To get access to the modules objects you write.
import faces.lib.report
my_report = faces.lib.report.standard(project)
The import statement says, there is a module called faces.lib.report. The function standard is defined within that module. And can be accessed by prefixing the module name with a "." dot: faces.lib.report.standard. There is a variant of the import statement that imports names from a module directly into the importing module's symbol table.

from faces.lib.report import standard
my_report = standard(project)

or you can also write

from faces.lib import report
my_report = report.standard(project)

Because faces.lib.report means that lib.report is a submodule of the module faces. There is even a variant to import all names that a module defines:

from faces.lib.report import *
my_report = standard(project)

See Also:

python tutorial
For a quick understanding of python
.



Subsections