def file_output(file_object):
"""
Writes strings to a file, making sure there's a newline at the end
:param:
- `file_object`: opened, writable file or name of file to open
"""
from io import IOBase
if not isinstance(file_object, IOBase):
file_object = open(file_object, WRITEABLE)
while True:
line = (yield)
line = line.rstrip(NEWLINE) + NEWLINE
file_object.write(line)
评论列表
文章目录