How do you flush stdout?

18 views
Skip to first unread message

rssail

unread,
Apr 13, 2024, 12:30:22 PMApr 13
to spyder
I have the following:

import sys 
import os 
class Portfolio
    @classmethod 
    def menu(cls): 
        print("Main Menu"
       p = Portfolio() 
       p.clear_screen()  
       p.transaction() 

    def clear_screen(self): 
        os.system('cls' if os.name == 'nt' else 'clear'
         print(flush=True
        sys.stdout.flush() 

    def transaction(self): 
         print("Transaction Menu"

if __name__ == "__main__" : Portfolio.menu()

When I run this the screen clears AFTER not BEFORE transaction() is run. How can I correct that?

Reply all
Reply to author
Forward
0 new messages