Confusion About Classes

M.E.Farmer mefjr75 at
Thu Dec 30 07:42:05 CET 2004

Thanks for the followup,
I just wanted to mention that you still need to read that stuff thru
several times, because...
there are no variables in python (yea I know others will say otherwise
Yep, I said it, none.
There are NAMES, thats why there are NAMESPACES.
A name is just a reference or 'handle' to an object, because.....
everything in python is an OBJECT,(except for names, they are just
And before you go and wipe out all those double underscores note that
python uses double underscores as special methods and other internal
details( read the docs).
A quick example is :( yeah it's deja vu)
py>class bla:
...    def __init__(self):
...    def setData(self, data):
... = data
...    def getData(self):
...        return
...    def nullData(self):
...        self.setData(None)
Not all underscores method names are unnecessary.
__init__ is a special method that is called by python when we create an
instance of this class.  Most of the double underscore methods are
special  methods and are part of python( later you will see they can be
used for object customization )
Now back to self... self is reference to.. well self. Python is
explicit . A class has it's own namespace so we pass a referance around
to all it's member functions. when we set an attribute of a class it
can be done inside or out . is an example of setting a
attribute of an object from inside the class ( notice we referance
ourselves inside the class , because we are assigning the name to that
An example of settng attrbutes outside a class:
bl = bla()
bl.MyNewData = [1,2,3,4,5]

As a matter of fact a common use of a class is like a container to
store data.
class null:
a =null() = 'mike'
a.weight= 220
Sorry if it is incoherent, I am way past bed time .

More information about the Python-list mailing list