What about an EXPLICIT naming scheme for built-ins?
Marco Aschwanden
PPNTWIMBXFFC at spammotel.com
Thu Sep 9 03:36:04 EDT 2004
> My proposal is to create a new category in the documentation for all
> *builtin constructors*:
>
> bool(), complex(), dict(), float(), int(), list(), object(), str(),
> tuple()
>
> All built-in constructors share common behavior -- they return a new
> object of the given type, using the argument as an initializer.
> Reading about how constructors work in general will help one to
> develop a broader, and better, understanding of their real power.
As you said: They are constructors... hence this are all classes (or are
going to be). According to the Python style-guide they are supposed be
written with CamelCase. If those would be written as:
Bool(), Complex(), Dict(), Float(), Int(), List(), Object(), Str(), Tuple()
And in the case of sum() we keep it lower-case to indicate an action that
is taken on the input.
But it should have been File() instead of file()... it would have been
clear to the programmer that he is dealing with a class and can make (new)
instances (or derive) from them (in the future maybe)
In the case of file() (which is not preferred over open() and is not a
synonym - I know). It was a good move to rename open() to file() [open ->
what?; file --> Aha, we end up having a file-object!] but then it was only
half the step because File() would have been the right naming choice...
I already proposed that and it turned out that I was a hobgoblin and
against that you cannot defend yourself. They proposed to create create
references (Bool = bool, Complex = complex, etc.) if I couldn't live with
it - well, I struggle but I still live and hope for Python3K. 8o)
Cheers,
Marco
More information about the Python-list
mailing list