py.user.nexthttps://docs.python.org/2/library/functions.html#open
Чего платформозависимо?
…and ‘a’ for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position)Any questions?
py.user.nexthttps://docs.python.org/2/library/functions.html#open
Чего платформозависимо?
…and ‘a’ for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position)Any questions?
Shaman
https://docs.python.org/2/library/functions.html#open
ShamanЭто далеко не some, а практически на всех линуксах происходит.
which on some Unix systems
#!/usr/bin/env python3 with open('file.txt', 'a+b') as fout: fout.write(b'a1') fout.seek(0) fout.write(b'a2') fout.seek(0) fout.write(b'a3')
O_APPEND
The file is opened in append mode. Before each write(2), the
file offset is positioned at the end of the file, as if with
lseek(2). O_APPEND may lead to corrupted files on NFS file sys‐
tems if more than one process appends data to a file at once.
This is because NFS does not support appending to a file, so the
client kernel has to simulate it, which can't be done without a
race condition.
...
CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001.