Is 'file' a keyword in python?

折月煮酒 提交于 2019-11-27 22:38:59

No, file is a builtin, not a keyword:

>>> import keyword
>>> keyword.iskeyword('file')
False
>>> import __builtin__
>>> hasattr(__builtin__, 'file')
True

It can be seen as an alias for open(), but it has been removed from Python 3, as the new io framework replaced it. Technically, it is the type of object returned by the open() function.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!