The open builtin function can open files in different modes. These modes are provided as a combination of characters. Using an invalid
sequence of characters will make open fail with a ValueError.
A valid mode:
- should contain only one of the following characters:
r (read), w (write), a (append), x
(create).
- should contain zero or one of the following characters:
t (text), b (binary).
- should contain zero or one
+ character (open for updating)
For example: a, rt, r+ and w+b are valid modes.
If no t or b character is provided the mode will default to t (text), so specifying r is
equivalent to rt.
Note: In Python 2, providing an incorrect mode may have an undefined behavior (ex: it might ignore some characters)