Skip to content

bar.text() in finalize is not effective #299

@ulgens

Description

@ulgens

I was trying to use bar.text() in finalize to print a success message when the iteration is done. Because the text gots cleaned right after the iteration is done, setting bar.text in finalize seems practically useless.

from time import sleep

from alive_progress import alive_it

bar = alive_it(
    range(1000),
    finalize=lambda bar: bar.text(f"{bar.current} items processed."),
)

for item in bar:
    bar.text(f"Processing item {item}")
    sleep(0.001)

Image

Is this expected behaviour or is there a parameter/approach I'm missing? If this is expected, I think

# from README.md
alive_it(items, finalize=lambda bar: bar.text('Success!'))

should be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions