Creating True Global Functions by Modifying Builtins

Peter Hansen peter at engcorp.com
Thu Jun 10 09:58:26 EDT 2004


Andrew Clover wrote:

> Peter Hansen <peter at engcorp.com> wrote:
> 
>>The only time I've found a valid reason to stick stuff in __builtin__
>>is when trying to make current code *forward compatible* with newer
>>versions of Python, such as when bool() and True/False where added
>>in 2.2 (?) and we had to stick with 2.0.
> 
> Even this isn't really a good idea. Many other modules have various
> different workarounds for lack of feature support, which if you are
> unlucky can get confused by builtin-hacking.

You're right in general, but what I didn't mention was that
this was code intended for an embedded system with total
control on what was present or not.  It was not on code
meant for general distribution to the outside world.  As
such, it served the purpose perfectly well, without any
such negatives.

 > Having a 'constants' module from which a package can from ... import *
 > is usually a better approach.

Quite true, in most cases.

-Peter



More information about the Python-list mailing list