Ordering python sets

Terry Reedy tjreedy at udel.edu
Sat Nov 1 23:17:16 CET 2008


Lie Ryan wrote:

> You need to adjust the current mindset slightly (but in an important way 
> to understand the "why" behind this idea). The current notion is: list 
> and dict is a data structure. With this idea, list and dict is an 
> abstract type, not a data structure. array, linked list, binary tree, red-
> black tree, hashed are data structure. 

Did you miss my earlier post?  Python already has about 20 abstract 
types.  It has a naming scheme for these, as well for concrete 
structures, both built-in and imported.  Agitating for names to be 
swapped around is a waste of time.  You are free, however, to do this in 
your own code.

 > We create a data structure by
> passing the data structure's identifier string to a factory function 
> provided by the abstract type.

Python is object-oriented rather than name-oriented.  When one knows the 
name of an object at compile time, the Python way is to use it directly 
in the code, unquoted.  In other words, work with and pass around 
objects as much as possible and only use names when they are truly 
variable and not known constants.

What you propose is equivalent to using getattr for all attribute 
access: "getattr(list, 'append')" versus "list.append".

Terry Jan Reedy




More information about the Python-list mailing list