Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between python file operation modules open and file.

Tags:

python

I am working on file operation in python, i found two module, What is difference between the two file operation module "open" and "file" functionality wise i found both same.

thanks.

like image 229
Shashi Avatar asked Feb 23 '23 10:02

Shashi


1 Answers

Python 2.x documentation says it all:

When opening a file, it’s preferable to use open() instead of invoking this constructor [file()] directly. file is more suited to type testing (for example, writing isinstance(f, file)).

In Python 3.x, file is no longer available.

like image 136
NPE Avatar answered Feb 26 '23 00:02

NPE