DEV Community

Discussion on: Why is there no error when we open the file twice in Python ?

Collapse
 
rhymes profile image
rhymes

Exactly David.

Imagine if one process had the ownership of a file descriptor for its entire lifetime. You couldn't open a file in two editors or synchronize content between a writer or a reader. You couldn't even open a file to have multiple writers. Unix pipes wouldn't probably work as well.

If you need lock everyone else out, that should definitely be an explicit request.

There's no real cost to have multiple readers so why block it by default? Locking is needed with multiple writers

Collapse
 
ddsry21 profile image
DDSRY

Thank you for sharing this✌