= DevelopOnTheWeb

Python



Python is an interpreted, object-oriented, high-level programming language. This page includes some notes about the language and details of some projects that I am working on and a few other examples.


Overview


Currently this is intended just to be collection of notes as I attempt to learn python. More structure will be added as time goes by.

Learning Resources

There are hundreds of tutorials, blog posts covering all manner of topics relating to Python programming. Here are some links that I have found useful and to which I refer - mainly when I have forgotten something.

Packages and Modules

Simply, a module is a file consisting of Python code. A module can define functions, classes and variables. Any python source file can be used as a module by importing -

import modulename
from foo import bar

When the python interpreter encounters an import statement, it imports the module if the module is present in the search path. A search path is a list of directories that the interpreter searches before importing a module.

|-- project
   |-- foo
   |   |-- __init__.py
   |   |-- bar.py
   |-- main.py

In main.py we might have the following :-

from foo.bar import add

number = add(1,2)

Or we count say :-

from foo import bar

number = bar.add(1,2)

In the first example only the add function is imported into the current namespace. In the second example the module bar is imported and as a result we have to use the module name when invoking the add function.

Lambdas