reassign to builtin possible !?

Benjamin musiccomposition at gmail.com
Thu Jan 3 13:38:08 EST 2008


On Jan 3, 7:04 am, Bernhard Merkle <bernhard.mer... at googlemail.com>
wrote:
> Hi there,
>
> I am reading Learning Python 3e from Mark Lutz and just found out that
> reassigning to builtins is possible.
> What is the reason, why Python allows this ? IMO this is very risky
> and can lead to hard to find errors.
I don't think it's a huge issue. In fact, I think it's a feature. For
example, it'd be extremely issue to reassign open, if you wanted to
implement a virtual file system, and you couldn't modify the module
the used open.
> (see also Learning Python 3e, Chapter 16, Page 315)
>
> >>> True
> True
> >>> False
> False
> >>> True = 1
> >>> True
> 1
> >>> True = 0
> >>> True
>
> 0
>
> TIA,
> Berni




More information about the Python-list mailing list