Advertisement
Lucas_Malor

Enum for Python open() modes

Aug 22nd, 2019
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from enum import Enum
  2.  
  3.  
  4. class OpenMode(str, Enum):
  5.     _binary = "b"
  6.     _update = "+"
  7.    
  8.     read = "r"
  9.     truncate_and_write = "w"
  10.     exclusive_create = "x"
  11.     append = "a"
  12.     update = read + _update
  13.     truncate_and_update = truncate_and_write + _update
  14.     exclusive_create_and_update = exclusive_create + _update
  15.     append_and_read = append + _update
  16.     read_binary = read + _binary
  17.     truncate_and_write_binary = truncate_and_write + _binary
  18.     exclusive_create_binary = exclusive_create + _binary
  19.     append_binary = append + _binary
  20.     update_binary = update + _binary
  21.     truncate_and_update_binary = truncate_and_update + _binary
  22.     exclusive_create_and_update_binary = exclusive_create_and_update + _binary
  23.     append_and_read_binary = append_and_read + _binary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement