Shashi
Shashi

Reputation: 2185

difference between python file operation modules open and file.

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.

Upvotes: 4

Views: 407

Answers (1)

NPE
NPE

Reputation: 500713

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.

Upvotes: 8

Related Questions