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? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

27th Dec 2018, 7:30 PM
Punyasloka Sahoo
Punyasloka Sahoo - avatar
2 Answers
+ 6
del print
27th Dec 2018, 7:34 PM
Anna
Anna - avatar
+ 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?
27th Dec 2018, 8:35 PM
Seb TheS
Seb TheS - avatar