For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Method, Class, Module, Package - how to they relate in Python?
A file containing a number of python methods and classes is known as a module
. In the simplest of cases, it mighy just contain one class.
A directory containing a number of python modules is known as a package
. In the simplest of cases, it may just contain one module
Here's a sample program that loads a class (or two) from within a module from within a package:
In Python 2
iHave = bundle.thing.matchbox("catapillar")
, you are required to mark a package as being a package by having a file called __init__.py
in the directory. This was described as being necessary to avoic confusion between module names if your package contained modules of the same name as standard modules. Failure to provide the file results in:
WomanWithCat:flask grahamellis$ python bundemo
In Python 3
Traceback (most recent call last):
File "bundemo", line 2, in <module>
ImportError: No module named bundle.thing
there is no such requirement for a __init__.py
WomanWithCat:flask grahamellis$ python3 bundemo
A Matchbox containing catapillar
Although not needed in Python 3, both versions support the file whichc also allows the specificiation of code to be run on load, and allows you to define a __all__
variable which controls what you load when you import
Files in this demo:
to go within package
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesY103 - Python - Conditionals and Loops 
What - no switch or case statement? - (2005-05-03) 
Wimbledon Neck - (2005-06-20) 
The ternary operator in Python - (2006-03-25) 
Python - block insets help with documentation - (2006-04-04) 
New - Conditional expressions in Python 2.5 - (2006-07-01) 
Python - when to use the in operator - (2006-08-16) 
Python is like a narrowboat - (2006-10-30) 
No switch in Python - (2007-05-23) 
Decisions - small ones, or big ones? - (2007-12-18) 
Equality, sameness and identity - Python - (2008-05-31) 
Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04) 
Learning to program in Python 2 ... and / or in Python 3 - (2010-05-24) 
Groupsave tickets - 3 or 4 train tickets for the price of 2 - (2010-08-02) 
Python - fresh examples from recent courses - (2010-12-11) 
How a for loop works Java, Perl and other languages - (2011-03-12) 
Does a for loop evaluate its end condition once, or on every iteration? - (2011-08-18) 
Python for loops - applying a temporary second name to the same object - (2011-09-14) 
Python or Lua - which should I use / learn? - (2011-12-21) 
Finding the total, average, minimum and maximum in a program - (2012-02-22) 
Learning to program - the if statement. Python. - (2012-06-12) 
Flowchart to program - learning to program with Well House - (2012-10-14) 
Identity in Python - (2013-05-17) 
If elif elif elif - multiway selection in Python - (2013-11-16) 
Learning to Program - the conditional statement (if) - (2014-11-21) 
Learning to program - Loop statements such as while - (2014-11-22) 
Finding sum, minimum, maximum and average in Python (and Ruby) - (2015-01-19) 
Setting up and tearing down with the Python with keyword - (2015-10-16) 
Equality (in Python) - (2016-10-30) 
Conditional operators in Python - (2016-11-05)
Some other Articles
Clarrissa-Marybelle - too long to really fit?Melksham - two small townships, or one big one?RUH Hopper - experience and thoughts forwardIs the RUH hopper a limited, duplicate service running unnecessarily and at high cost?Method, Class, Module, Package - how to they relate in Python?RSpec - Ruby testing (stand alone example / no cucumber)Saturday morning at Well House ManorThe principle of mocking - and the Python Mock packageUnittest of a Flask application including forms
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).