Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>: > Marko Rauhamaa wrote: > >> I've reached a point where I think classes are a superfluous OO concept. >> You only need objects. > > I don't know whether "superfluous" is correct, but they certainly are > *optional*. There are at least two types of object oriented programming: > class-bases, and prototype-based.
And I'm talking about a third kind: object-based. It is in active (albeit limited) use in scheme: <URL: http://irreal.org/blog/?p=40>. I'm currently using the principle in a project of mine. In Java, you use anonymous classes for the same thing. In Python, you can think of the principle as one-time classes. So instead of writing: class A: def __init__(self, x, y, z): self.x = x self.d = y * y + z * z def f(self): return self.x - self.d you write: def A(x, y, z): d = y * y + z * z class Anonymous: def f(self): return x - d return Anonymous() Now, if you always did this, you would notice that classes are unnecessary clutter and would call for syntax like this: def A(x, y, z): d = y * y + z * z return object: def f(): return x - d Marko -- https://mail.python.org/mailman/listinfo/python-list