Safe to import __builtin__ ?
steve at REMOVE-THIS-cybersource.com.au
Wed Jun 3 18:54:30 EDT 2009
On Wed, 03 Jun 2009 18:57:29 +0000, Benjamin Peterson wrote:
> mrstevegross <mrstevegross <at> gmail.com> writes:
>> Is it generally safe to explicitly import __builtin__ in python? That
>> is, my code reads like this:
>> It seems like it should be a safe import, but I just want to make sure.
> Yes, that's fine. I'm not sure why you don't just use type(), though.
I'm not sure why you think type() is a substitute for __builtin__. Here's
a typical use-case for __builtin__:
def map(*args): # shadow a built-in
# pre-processing goes here
result = __builtin__.map(*args)
# post-processing goes here
How does type() help you?
More information about the Python-list