0

What is the difference when opening a file via the following two methods? open(name, mode=None, buffering=None)' from __builtin__.py versus os.open signature: open(filename, flag, mode=0777)

When should I use each of them?
I've also heard of the existence of io.open

JavaSa
  • 5,813
  • 16
  • 71
  • 121
  • There are huge differences. Look at the return type; the `os` call is a *low level* call, the `open()` built-in high-level. Stick to the latter unless you know what you are doing (e.g. know how to use a file descriptor (an integer) to access the file. – Martijn Pieters Jun 11 '15 at 12:50
  • Possible duplicate? http://stackoverflow.com/questions/7219511/whats-the-difference-between-io-open-and-os-open-on-python – asherbret Jun 11 '15 at 12:51
  • The `io` module is the new Python 3 I/O framework, it replaced the older Python 2 implementation. It is available in Python 2 so you can write code that works on both Python 2 and 3, or you can use it because it is so much better than the old way. – Martijn Pieters Jun 11 '15 at 12:51

0 Answers0