Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

print() in a loop doesn't output until the loop is done #825

Open
@jean

Description

@jean

I paste some code into the BPython REPL.
It looks like nothing happened, I don't even see the code I pasted, but it is running.

When I interrupt the loop, all this appears at once:

>>>importtime>>>>>># seen_nodes = []>>># dupe_nodes = []>>>counter=0>>>forrowincol.get_rows():...node_id=row.get_property('node_id') ...if (node_idinseen_nodes)and (node_idnotindupe_nodes):...dupe_nodes.append(node_id)...elifnode_idnotinseen_nodes:...seen_nodes.append(node_id)...counter+=1...ifnotcounter%2:...print(f'{counter:6} | seen:{len(seen_nodes)}, dupes:{len(dupe_nodes)}',flush=True)...time.sleep(1)...2|seen:12530,dupes:1004|seen:12530,dupes:1026|seen:12530,dupes:1048|seen:12530,dupes:106Traceback (mostrecentcalllast):File"<input>",line10,in<module>time.sleep(1)File"/home/jean/.local/lib/python3.8/site-packages/bpython/curtsiesfrontend/coderunner.py",line176,insigint_handlerraiseKeyboardInterrupt()KeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp