开发者

Why cannot pass print function to dir() in python?

开发者 https://www.devze.com 2023-04-06 09:44 出处:网络
Is print a built-in function? If it is, why I cannot run dir(print)? dir is a built-in function and dir(dir) works we开发者_开发问答ll. So it looks very strange to me that dir(print) could not work.In

Is print a built-in function? If it is, why I cannot run dir(print)? dir is a built-in function and dir(dir) works we开发者_开发问答ll. So it looks very strange to me that dir(print) could not work.


In python 2 print is a statement and not a function and you can't put a statement as a function argument, in the other hand in python3 print is a function so you can do dir(print).

0

精彩评论

暂无评论...
验证码 换一张
取 消