+ 1
If we reasign a built in function in Python, it loses it's original behaviour, then how can we get the original behaviour of it?
Eg. In Python if I write print=34, it will lose it's original behaviour ie it won't print text into IDLE and behave like a variable. How can we get back print to it's original behaviour like print text into IDLE.
2 ответов
+ 6
del print
+ 1
__builtins__.print()
If name is used (variable name or function name) Python first searches it from local namespace.
If Python doesn't find the name from locals, it searches the name from global namespace.
If Python doesn't find the name from global namespace it searches the name from the builtin namespace.
If Python doesn't find the name from builtin namespace, it raises an error, NameError.
What if Python doesn't find NameError?