-
Notifications
You must be signed in to change notification settings - Fork 181
Description
Hello, I have looked at the current implementation of Tree.show function in the master branch. I think the previous design is a bit confusing.
When stdout=True, I understand it to be using sys.stdout.buffer.write so I can directly write bytes to the console. However in tree.py line 932. It simply prints out the bytes with the print function. I don't understand why it was designed like that.
Refer to #215 , if the idea of stdout=True was to simply output to the console, then this is conflicting among users as I and this #230 have issues with encoding. I have to do print(tree.show(stdout=False) which makes stdout=True useless.
I suggest an improvement with the following:
if stdout:
return self._reader.encode("utf-8")
else:
return self._readerOr add an encoding parameter to the show function, allowing use to choose #tree.show(encoding='utf-8') if we having trouble with the final print.
if stdout:
if encoding is not None:
print(self._reader.encode(encoding))
else:
print(self._reader)
else:
return self._reader