static class methods in Python?

Neel Krishnaswami neelk at
Sat Feb 19 03:03:45 CET 2000

Aahz Maruch <aahz at> wrote:
> In article <slrn8arn3d.9md.neelk at>,
> Neel Krishnaswami <neelk at> wrote:
> >
> >This is probably a stupid question, but what /is/ a class method?
> >I've never programmed in C++ (or Java), so an explanation would be
> >appreciated.
> Class methods are used to access and modify class variables.  For
> example:
> class foo:
> 	bar = None
> 	def __init__(self):
> 		pass
> 	classdef isdone():
> 		if is not None:
> 			return "!!!"
> 	classdef clear():
> = None
> Clearer?

Yes, thanks. 

I'd agree that the you'd have to do in real Python
is a little bit ugly. One thing I looked at doing was changing Python
so the syntax "" would expand to "" (or
whatever "self" actually is). This would solve the problem without
adding a new keyword.

However, I was scared away by the following comment in Parser/pgen.c:

	/* This algorithm is from a book written before
	   the invention of structured programming... */



More information about the Python-list mailing list