Classes in Python
Dave Brueck
dave at pythonapocrypha.com
Fri Apr 18 16:12:22 EDT 2003
On Fri, 18 Apr 2003, Steven Taschuk wrote:
> Quoth Bill Martin:
> > I'm wondering about the value of allowing a class definition like this:
> >
> > class C:
> > pass
[snip]
> One slightly different form which I find very useful:
>
> class HullBreachError(Exception):
> pass
Another use is if you don't like the 'global' keyword much:
class GV: pass
GV.someCounter = 0
GV.someOtherVar = 'foo'
def Biff():
GV.someCounter += 1
That way it's perfectly obvious that something is global.
(I hope this doesn't start the "why do I have to type 'self.'" thread yet
again, although it _has_ been almost a week so it's overdue <0.5 wink>).
-Dave
More information about the Python-list
mailing list