[Tutor] special attributes naming confusion

Steven D'Aprano steve at pearwood.info
Sat Jun 9 10:26:54 CEST 2012


Alan Gauld wrote:

> In general someone "just learning python" doesn't need to know about 
> special names, they just use the operations they define.
> The only exception being __init__() in class definitions.
> 
> These methods are really only of interest to someone who wants to define 
> their own abstract data type and make it look like a built in type(*). 
> In the vast majority of beginner scenarios that is not
> needed or can be faked without use of them.

I mostly agree with this, more or less, although I would like to correct your 
terminology. "Abstract data type" does not mean what you seem to think it 
means here. I think you mean concrete types, not abstract. Types which look 
like the built-in strings, numbers, lists etc. are concrete types, not abstract.

Working with abstract types is a relatively advanced thing to do, at least in 
Python, but concrete types are very common.

In computer science, an abstract data type is a theoretical entity  used for 
reasoning about algorithms, rather than an actual programming type. For 
example, you might define an abstract list type with certain methods, without 
caring about the actual details of how you would program such a list.

These leads to the other common sense of "abstract", as in "abstract base 
class" or ABC, which is a class which cannot be instantiated. ABCs must be 
subclassed before you can use them.


-- 
Steven



More information about the Tutor mailing list