PyWart (Terminolgy): "Class"

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Jan 14 12:26:37 EST 2013


On Sun, 13 Jan 2013 22:46:44 -0800, Rick Johnson wrote:

> I have believed for a very long time that "class" was a poor choice of
> keyword to designate an "object definition".
> 
> Firstly, the word /class/ does not transform smoothly into CS from
> English. NO English definition of "class" comes anywhere close to
> describing the "structured source code that defines an object".  Or even
> generally as: "something that defines something else".


Your knowledge of English has failed you. Here is the first definition 
from Webster's Dictionary (1913 edition):


Class \Class\ (kl[.a]s), n. [F. classe, fr. L. classis class,
   collection, fleet; akin to Gr. klh^sis a calling, kalei^n to
   call, E. claim, haul.]
   1. A group of individuals ranked together as possessing
      common characteristics; as, the different classes of
      society; the educated class; the lower classes.
      [1913 Webster]


And definitions 3 and 4:


   3. A comprehensive division of animate or inanimate objects,
      grouped together on account of their common
      characteristics, in any classification in natural science,
      and subdivided into orders, families, tribes, genera, etc.
      [1913 Webster]

   4. A set; a kind or description, species or variety.
      [1913 Webster]


"Class" is an excellent ordinary English word to describe what computer 
science calls a "class".



> Thirdly, once people *DO* understand that a "class" is simply an "object
> definition", they still go on to say idiotic things like: "Classes are
> objects"! 

Your knowledge of Python has failed you.

Classes are objects in Python, although not in all other languages.

Classes are created at runtime, not compile time. They have an id, like 
all instances. They have a __class__ attribute, like all instances. They 
have a type, like all instances. They *are* instances.

py> class Spam(object):
...     pass
...
py> id(Spam)
168149924
py> isinstance(Spam, type)
True


> It is obvious these people are a victim of their own terminology.

You're very funny.


> "subclass":
>     Since every "user defined object" *must* subclass /something/, 

Only in Python 3. In Python 2, some classes are not subclasses.

py> class OldStyleClass:
...     pass
...
py> OldStyleClass.__bases__
()


> "template":
>     This term is very close, but still lacking a concrete relationship
>     between source code (definition of object) and the resulting "thing"
>     living in memory (object). I think this one is TKO in round 3.

A template is certainly not correct for class-based OOP languages like 
Python, since it implies *copying*. It might be more appropriate for 
prototype-cased OOP languages like Javascript.


[...]
> Now since "methods" and "functions" (PyWart on these terms coming soon!)

Oh I can barely contain my excitement.


-- 
Steven



More information about the Python-list mailing list