Closed thmsklngr closed 4 years ago
Hello @mosesontheweb, thank you, appreciated!
Unfortunately, I can't imagine how this would be possible. Note the code doesn't even include a print(i)
to cause that output.
Are you really sure this was the code you ran? Which version are you using? Which Python?
I've simulated it now, latest version in a Python 3.8:
Regards, Rogério.
Hey, that's bizarre! I don't have the slightest idea how that could happen, I'd say it's impossible without manually fiddling with the source files...
Could you please try in a new virtualenv? I like pyenv-virtualenv very very much, it just takes:
$ pyenv virtualenv 3.6.9 alive-test
$ pyenv shell alive-test
And this shell has that venv activated. Then you could:
$ pip install alive-progress
$ python
Could you please try that?
Well, please reopen if you have more information.
Hey @mosesontheweb, how are you?
~Why didn't you tell me this was occurring on Windows? It would be super relevant...~
Anyway, I just installed Python on a Windows machine, and experienced this exact issue!
All I can say for now is that it really is the bar()
handle, but don't have a clue why.
Every time it is called, a new line gets printed.
The relevant code seems to be my flush_buffer
, which is called on every bar call. That is because if there's anything on print_buffer
, it must be flushed to get the correct count, before incrementing it. There it does have a print()
statement.
https://github.com/rsalmei/alive-progress/blob/master/alive_progress/core/progress.py#L121-L123
But for anything to enter the print_buffer
, it must be in:
https://github.com/rsalmei/alive-progress/blob/master/alive_progress/core/progress.py#L163-L167
Would it be the \n
? Maybe on Windows it would be \r\n
?
I'm going to open this again, and do some more debugging.
Humm, inside WSL (Windows Subsystem for Linux) it does work. Because it's ipython, not because of WSL.
Awesome, I found it!!!!
Regardless of how bizarre it may seem, it's the return value of bar()
that is being printed on screen!
I don't know why this Python is doing that, but just commenting that return makes it all work nicely! 😄
Ok, I've been using ipython
and bpython
for so long in my live that I've forgot about this quirk.
It's because of Python
, the default REPL, that this happens. It has nothing to do with Windows.
Even on macOS I can simulate, it is because Python
does not know how to ignore a return value. ipython
on the other hand, interprets the statement differently, and captures only its final output:
That way, what I am going to do: I'll remove the return value by default, and create a new method called bar.current()
that will return the current position if needed.
It will be available in the next major 2.0! See #51
Hi, sorry for the late reply. I thought that I mentioned it somewhere, but it seems that I didn't. My bad. But glad to see that you were finally able to reproduce the issue and add a fix in the next major.
Regards, Thomas
Hi,
I just installed your lib, it's great. Unfortunately I have an issue, which I can't explain.
I used your same code:
Result:
So, even though I do not have any kind of print command, there's output.
Any ideas why?
Regards, Thomas