lower-case names for builtin types

E

Eric Snow

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.

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?

-eric
 
S

Steven D'Aprano

Eric said:
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@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
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.
 
R

rantingrick

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.

Or it could be that they wanted to hoard all the good generic variable
names!
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").

Yes!

Some folks get all huffy about this subject because they get SO
attached to built in functions. What's so weird about calling a
function that THEN calls a constructor as opposed to just calling the
constructor directly? Seems like unnecessary overhead to me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top