[Tutor] When to use a Class or just define functions?

Alan Gauld alan.gauld@blueyonder.co.uk
Fri Jun 20 18:38:02 2003


> >literally nothing! Classes are only useful if you put some methods
> >inside them.
> [snip]
> Oh I disagree. A class can do what a C struct does; collect
properties that
> have potentially differing values for various instances, and no
methods.

Good point Bob. I was thinking in the context of the question about
putting functions in classes or modules. However classes without
functions can still be useful if they have attributes.

In fact even a 'pass' class like the one under discussion can be
useful
in Python since we can add attributes at runtime to instances.
However, in general, empty classes(no attributes or methods) are
pretty useless.

Alan g.