if STREAM.isatty():
Hongyi Zhao
hongyi.zhao at gmail.com
Thu Aug 29 18:38:42 EDT 2019
On Thu, 29 Aug 2019 16:42:44 +0100, Rhodri James wrote:
> I don't understand what's to not to understand.
>
> if condition:
> do_something_because_condition_is_true()
> else:
> do_something_because_condition_is_false()
>
> is a perfectly normal construction. If you mean something else, please
> be explicit.
Let me say it more explicitly:
The original code snippet's logic is as follows:
if STREAM.isatty():
p = (self.progress_template + '\r') % params
else:
[do something to reset the new value of p]
p = (self.progress_template + '\n') % params
STREAM.write(p)
STREAM.flush()
In order to refresh the tty, the if and else must be run alternatively.
i.e., the isatty() must return 0 and 1 periodically.
I still understand how the above code will let the isatty() return 0 and
1 in turn?
Regards
More information about the Python-list
mailing list