3. Function : Introduction
Functions are reusable pieces of programs
Functions are defined using the def keyword
A function can take parameters
You can declare variables inside a function
definition
Functions can have optionals parameters too
Functions can have named arguments
Day 2
4. Function : Global statement
You can use the values of such variables defined
outside the function
Try to avoid the use of this global statement
Day 2
5. Function : Parameters
Parameters are specified within the pair of
parentheses in the function definition,
separated by commas.
Day 2
6. Function : Scope of Variables
the parameter passed in is actually a reference to
a variable (but the reference is passed by value)
some data types are mutable, but others aren't
Day 2
7. Function : Default Argument Values
Used when you want to declare as an optional
argument
default argument value should be a constant
(immutable)
Day 2
8. Function : Keyword Arguments
You can give values for such parameters by
naming them - this is called keyword arguments
we use the name (keyword) instead of the
position, to specify the arguments to the
function.
Benefits of this feature
no need to remembers the order
we can give values to only those parameters which
we want
Day 2
11. Function : return
The return statement is used to return from a
function i.e. break out of the function.
We can optionally return a value from the
function as well.
In python can return one or move values
Day 2
13. Function : DcdocStrings
documentation strings which is usually referred
by docstring
important tool, you should make use of it
we can even get back the docstring
from, say a function, when the program is
actually running!
Day 2
16. OO : Introduction
Declare a class with class keyword followed by
class name
class NewStyle(object):
""" NewStyle class decleration in Python 3.0 """
pas s
class OldStyle:
Day 2
17. OO : class and constructor
Creating constructors in Python is really easy;
Simple create a method __init__
Day 2
18. OO : arguments to constructor
Constructor is an like an methods
We can pass arguments to constructors
Day 2
25. OO : Iterator and generator
Iterator objects in python conform to the iterator
protocol
which basically means they provide two methods:
__iter__() and next()
The __iter__ returns the iterator object and is
implicitly called at the start of loops.
The next() method returns the next value and is
implicitly called at each loop increment.
next() raises a StopIteration exception when
Day 2
29. Next Session ?
Installation of OpenERP
Working with LP
Understanding structure - Architecture
Customization Without Developments
Exercise: Room Reservation
Module - Minimal Structure
Module structure
Hello World – First module to OpenERP
Day 2