Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tqdm.write() "end" argument not working #520

@flyingdutchman

Description

@flyingdutchman

Hello !
I am having issues with the usage of a carriage return with tqdm.write()

This code works perfectly, it make an animation of a spinning bar

for x in range (0,50):
    tqdm.write("|/-\\"[x % 4], end='\r')
    time.sleep(0.1)

But if I create progress bar just before :

bar = tqdm(total=100)  # Here
for x in range (0,50):
    tqdm.write("|/-\\"[x % 4], end='\r')
    time.sleep(0.1)

I have just a display of the progress bar.

This is an issue imo because the tqdm.write should emule the behaviour of print() since nothing is precised in the documentation.

Edit :
This problem can be generalized to any value of the end argument that is not \n
(Made some test running both programs with a space or an other character instead of the return carriage. The first code shows the expected output but the second have exactly the same issue)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions