Please help me to understand classes
Johann Spies
Johann.Spies at p98.f112.n480.z2.fidonet.org
Wed Jun 30 04:14:49 EDT 1999
From: Johann Spies <jhspies at futurenet.co.za>
On Tue, 29 Jun 1999, Stidolph, David wrote:
> Finally, a simple question I can answer!
>
> First of all, class methods like "druk" need to have a parameter declared in
> them called self (or whatever you want to call it). Secondly you need to
> call the method with open/close parens:
>
> class A:
> def druk(self):
> print 'Jy is in Class A'
>
> class B:
> def druk(self):
> print 'Jy is in Class B'
>
> a = A()
> c = B()
> c.druk()
> Jy is in Class B
> a.druk()
> Jy is in Class A
>
> I hope this helps,
Thanks David. It helped. After your message I went back and read the
tutorial again and saw what you mean.
Johann
--------------------------------------------------------------------------
| Johann Spies Windsorlaan 19 |
| jhspies at futurenet.co.za 3201 Pietermaritzburg |
| Tel/Faks Nr. +27 331-46-1310 Suid-Afrika (South Africa) |
--------------------------------------------------------------------------
"Because he himself suffered when he was tempted, he
is able to help those who are being tempted."
Hebrews 2:18
More information about the Python-list
mailing list