Author thautwarm
Recipients steven.daprano, thautwarm, vtheno athena
Date 2018-10-03.10:29:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1538562570.07.0.545547206417.issue34880@psf.upfronthosting.co.za>
In-reply-to
Content
Reply to this:
> How is that different from every other case of shadowing a builtin?
> 
> len = 45
> print(len("hello world"))

```
AssertionError = 42
assert 1 != 2
```

`assert` implicitly invokes `AssertionError`, while `len` does that explicitly.  That is to say, simply changing a global variable breaks the work of a keyword.

Another difference is that shadow builtins could be resumed in the 
nested functions without something like `globals()` or `exec(..., {})`, while you cannot perform this to the breakage of `assert`:

```

len = 1
def g():
   from builtins import len

   return len([1, 2, 3])

g() # => 3

AssertionError = +1

def f():
   from builtins import AssertionError
   assert False

f() # boooom


```
History
Date User Action Args
2018-10-03 10:29:30thautwarmsetrecipients: + thautwarm, steven.daprano, vtheno athena
2018-10-03 10:29:30thautwarmsetmessageid: <1538562570.07.0.545547206417.issue34880@psf.upfronthosting.co.za>
2018-10-03 10:29:30thautwarmlinkissue34880 messages
2018-10-03 10:29:30thautwarmcreate