mirror of https://github.com/tqdm/tqdm.git
cleaner solution
This commit is contained in:
parent
5fbbd7369b
commit
1fd2234a0b
|
@ -308,15 +308,14 @@ class tqdm(object):
|
|||
|
||||
# Clear all bars
|
||||
inst_cleared = []
|
||||
if hasattr(cls, '_instances'):
|
||||
for inst in cls._instances:
|
||||
# Clear instance if in the target output file
|
||||
# or if write output + tqdm output are both either
|
||||
# sys.stdout or sys.stderr (because both are mixed in terminal)
|
||||
if inst.fp == fp or all(f in (sys.stdout, sys.stderr)
|
||||
for f in (fp, inst.fp)):
|
||||
inst.clear()
|
||||
inst_cleared.append(inst)
|
||||
for inst in getattr(cls, '_instances', []):
|
||||
# Clear instance if in the target output file
|
||||
# or if write output + tqdm output are both either
|
||||
# sys.stdout or sys.stderr (because both are mixed in terminal)
|
||||
if inst.fp == fp or all(f in (sys.stdout, sys.stderr)
|
||||
for f in (fp, inst.fp)):
|
||||
inst.clear()
|
||||
inst_cleared.append(inst)
|
||||
# Write the message
|
||||
fp.write(s)
|
||||
fp.write(end)
|
||||
|
|
Loading…
Reference in New Issue