scripts: Adopt __get__ binding for write/writeln methods
This actually binds our custom write/writeln functions as methods to the
file object:
def writeln(self, s=''):
self.write(s)
self.write('\n')
f.writeln = writeln.__get__(f)
This doesn't really gain us anything, but is a bit more correct and may
be safer if other code messes with the file's internals.
This commit is contained in:
@@ -877,10 +877,10 @@ def main(csv_paths, output, *,
|
||||
|
||||
# create svg file
|
||||
with openio(output, 'w') as f:
|
||||
def writeln(s=''):
|
||||
f.write(s)
|
||||
f.write('\n')
|
||||
f.writeln = writeln
|
||||
def writeln(self, s=''):
|
||||
self.write(s)
|
||||
self.write('\n')
|
||||
f.writeln = writeln.__get__(f)
|
||||
|
||||
# yes this is svg
|
||||
f.write('<svg '
|
||||
|
||||
Reference in New Issue
Block a user