12

I'm new to python and, looking at the docs, saw that there are at least two ways of opening a file for access os.open and open. What is the difference between os.open and open?

When should I use os.open?

When should I use open?

Peter Wood
  • 23,859
  • 5
  • 60
  • 99
Mattias
  • 1,331
  • 3
  • 11
  • 11
  • 3
    Duplicate aside, why wouldn't you just read the documentation for both? That's what it's for. – Cairnarvon Jun 11 '13 at 18:38
  • I think this question is about using an advanced IDE :) It tells you that open is not defined, and that `import os` is not required. Trying to fix it via "os.open" causes the wrong open function to be called (but fixes the two warnings.) – nycynik Jan 08 '19 at 17:42

1 Answers1

15

It is mentioned in the documentation of os.open:

Note: This function is intended for low-level I/O. For normal usage, use the built-in function open(), which returns a file object with read() and write() methods (and many more). To wrap a file descriptor in a file object, use fdopen().

A. Rodas
  • 20,171
  • 8
  • 62
  • 72