Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact

Tips and short articles on this subject
Python Script - easy examples of lots of basics
Returning multiple values from a function (Perl, PHP, Python)
A better alternative to cutting and pasting code
Function / method parameters with * and ** in Python
It's the 1st, not the 1nd 1rd or 1th.
Sludge off the mountain, and Python and PHP
Python - A list of methods
Recursion in Python
Python - function v method
Dynamic functions and names - Python
Do not duplicate your code
Cottage industry or production line data handling methods
Python modules. The distribution, The Cheese Shop and the Vaults of Parnassus.
Python - block insets help with documentation
Python's Generator functions
Difference between import and from in Python
What is a callback?
Code and code maintainance efficiency
Call by name v call by value
Lambdas in Python
Python generator functions, lambdas, and iterators
Distance Learning
Variable Scope
Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Functions, Modules and Packages - Python module Y105
In Python, blocks of code can be named. Such named blocks of code can be run from elsewhere in your program, and are known as functions. A module is a text file that contains a number of functions and other items, and a package is a group of related modules.

This topic is presented on public course Python Programming

Examples from our training material
dream   Good structure of named blocks of code
electric.py   a generator function - carries on where it left off at previous call
extrastep.py   importing a name from a module into the current namespace
fat.py   A second program that uses shared functions in mod2.py
flook.py   Program to use a module and the attributes of its functions
fun.py   definition and use of a function
gen2   Using a generator function to provide an iteration
genex   Generator v regular function
local.py   File of functions to be loaded by other examples
locvar.py   Local and global variables
mapfunc.py   Use of the map function to transform a list
mod2.py   A module with doc strings and attributes defined
mod_demo.py   Program that uses the module in local.py
mystuff.py   functions, statics, test code, doc strings ...
params.py   Optional parameters, and variable number of parameters
passenger   Calling program - sample answer with separate module for functions
qv2   Example that uses mystuff.py
qv3   alternative example using mystuff.py
recur.py   Recursion - when a function calls itself
sheep.py   A Lambda function - one line function definition
silksheets.py   Functions that we'll share between applications
slumbermore   Good structure of named blocks of code
snoresleep   A further Good structure of named blocks of code
sweetdream   Another example of a module reuse
sysdemo.py   use of a standard module (sys)
tax.py   functions to work out tax and net from gross
taxi   Exercise answer - net and tax from gross amount
Opentalk forum discussions related to this topic
Should I use from or import
Variable scope in Python
Common Python questions
Pictures
Studious group during a practical
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
Why use functions.
A first function.
A first module.
More flexibility in calling functions.
Doc strings and function attributes.
Defining your own attributes.
Variable scope.
Advanced function capabilities and recent additions.
Lambda example.
Generator Example.
Recursion.
Built-in modules.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 600 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.



See also:

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho