My question arises from this question, in which a user got himself confused by unknowingly rebinding the built-in global set
. Is there a straightforward way to get python to warn you when you attempt to override a built-in?
I'm thinking more specifically of Mathematica. In Mathematica all built-ins have attribute Protected
. If you try to redefine Set
, it will tell you that Set
is Protected
and leave it unchanged, possibly saving you from massive confusion later on when things that ought to work stop doing so for no obvious reason. If you really seriously want to redefine Set
you can still do it -- you just have to Unprotect
it first. And you can Protect
your own symbols, too, to protect them from accidental redefinition.
Perhaps experienced pythoners don't need this, but it would be nice if there were something like this for newbies like me. (Come to think of it, I've been programming Mathematica for 15 years and Protected
still occasionally saves my bacon.)