lower-case names for builtin types

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Oct 2 00:11:10 EDT 2011


Eric Snow wrote:

> Anyone know the story behind the lower-case names for the
> non-exception built-in types (like list and type)?  I am guessing that
> they were originally factory functions that, at some point, graduated
> to full types; and the names were kept lower-case for backward
> compatibility.

Exactly.

[steve at sylar ~]$ python1.5
Python 1.5.2 (#1, Apr  1 2009, 22:55:54)  [GCC 4.1.2 20070925 (Red Hat
4.1.2-27)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> type(int)
<type 'builtin_function_or_method'>


> However, if we were to consider making a change for Python 4, I am not
> sure how I feel about Int("5") over int("5").  Maybe it would be
> Integer("5").
> 
> Regardless, perhaps the type names are still lower-case for some other
> valid reason.  If so, I would love to know what that is.  Is there any
> merit to having lower-cased class names?


Backwards compatibility and tradition.

Many languages have functions to convert a value into a string, integer or
float, which are usually written something like str(), int() and float().
It would seem strange to write them as Str(), Int() and Float() in Python
just because they happen to be types.

Maybe in Python 4000 there will be a push to rationalise the case of
built-in types.



-- 
Steven




More information about the Python-list mailing list