So I'm doing an MIT OCW assignment where I am creating a functional game of hangman. I got everything working. In IDLE, I have to hit F5 to run the code in the shell. I don't know any other way to run it, but that's not the big deal to me.
The main problem: the shell gets absolutely full of responses. It just keeps stacking up with more and more output. So, my question. Is it possible to put in a piece of code to clear the shell? Or do I just have to deal with it for now?
EDIT: To clarify:
I need the prints for each cycle. Every time the user guesses a letter, it prints something like this:
2 guesses remaining
Possible answers: abdfghijkpquvwxyz
Guess a letter:g
That letter is not in the word!
_ o_ _ _ tr_
I just want to know if there is a way I can clear what is in the shell before the next 'cycle' is printed.
You can close it and just open a new one when you want to run the program or run it from the terminal and use use clear after you exit the shell
Related
Extensions installed: Python, Code Runner
The problem is I was trying to enable the "clear previous output before each run setting"
But when I try running a simple code the output (in terminal) becomes glitchy.
The code I am running is:
print('hello')
a=input()
print(a)
Here is the first time I run the code in completely Blank terminal
The first attempt is pretty normal.
Here is the what happens when I run the code again
There is a lot of blank space in the terminal which becomes worse the third time I run the code
This blank space worsens till the 5th attempt and here is what happens on the sixth attempt.
Basically the blank space vanishes and all the previous attempts can be seen in the terminal. But that means the initial setting I intended did not apply and terminal does not get cleared before each run.
Can someone tell how to automatically clear terminal before each run.
"code-runner.clearPreviousOutput": true works well in OUTPUT panel, but does not work in the terminal.
Someone else has submitted a feature request for it. You can refer to this page and upvote it.
I have written a program which clocks how fast I write some text to improve my touch typing speed.
The thing is that I don't like that I have to press Enter to start the program and THEN start writing. I would like to start the program and let the timer set off exactly when I have pressed the first key.
I was thinking if it would be possible to use the first character of the text I should write instead of Enter to finish an input. If so, I could solve the problem.
I was wondering if anyone has some kind of advice on how I could do this or just solve the problem.
A quick search turned up the pynput module for me, it looks like something that you could easily build into what you are talking about.
screenshot of my pycharm interface
Hey everyone. When I run this simple code (the tab 'youtubeyf.py
is to print 'hello world'), it produces the intended result but also another script (with the tab name "yfinance.py") result as well. In fact, the "yfinance.py" script doesn't need to be open in order for that result to appear too. It is almost as if it runs in the background, parallel without being open.
Goal: I want to run "print 'hello world'" without the dataframe from the other script appearing.
Problem: the dataframe is appearing without actually running or being open.
Troubleshoot attempts so far: I have "Alphabetted" and searched on StackOverflow, JetBrains on topics regarding reconfiguring the "run configurations", "parallels", and nothing yet.
Thank you for your time.
Edit 1: this does not solve my problem. for one, my issue isn't importing. in fact, everything is "running" smoothly, but that the results are two in one. It is analogous to two chefs preparing one meal each, say shrimp lo main and pizza, and then placing both meals onto one plate. I don't want that; I want to have shrimp lo main on Tuesday night, and then pizza Wednesday.
When importing yfinance, it could be possible that in that module, your code is structured such that when you import the module it runs a function or other code. In yfinance, you should delete any extraneous function that doesnt need to be run everytime you import yfinance somewhere else.
Edit: what you can do, if you dont want to change much of the structure yfinance.py, is wrap all the code that runs in that python file inside a main function and add the following:
if __name__=="__main__":
main()
This makes it so that python only runs main if you're actually running yfinance.py , and doesnt run main when you're importing it.
This answer on Stack Overflow offers a solution I am trying to implement. In particular, see the sections "Installation Instructions" and "How to Use".
Can anyone tell me the steps required to "restart" IDLE?
New Information:
Just as people have suggested I thought this simply meant closing the program and opening it back up again...but I already tried that.
The other twist to my situation is that I'm working on a virtual machine so I was unable to do the installation of IDLE2HTML.py myself. My work's Help Desk had to do it so I cannot speak for the accuracy of their work. For now I'm assuming they did it correctly, but when I go to the "Options" menu there is no option to "Save as HTML".
My only guess at this point is that I still need to "restart IDLE".
Just wanted to double check if there was something else I could do before going back to my Help Desk department.
IDLE reads the idlelib/config-xyz.def files, including config-extensions.def, just once, when it starts. So any changes to config-extensions.def only takes effect the next time you start IDLE.
If you do not see 'Save as HTML' after starting IDLE, the extension is not installed properly.
It means you need to close the IDLE so that any changes made by the script can affect the IDLE
Simply close the IDLE either via the X, Ctrl+Q or File>Exit, then open the IDLE again.
If you are using idlelib module from a Python program then close your program and run it again.
I've tried the solution here - How to clear the interpreter console? - to clear the Console, and it works, but it still leaves the C:/Python27> line. Is there any way of clearing everything, including this? I'm new to Python, I'm trying to make a simple Noughts and Crosses game, for which I want a clear Console. I usually use VB.NET, where there are no input lines and this isn't a problem.
If this was me, I would see if I could perhaps control the size of the window being used, such that I know the exact number of lines on screen, and then print an exact number of blank lines such that the command prompt is not longer shown.
After this point, your noughts and crosses game I assume will print to screen multiple times, where each 'time' is going to be a new 'frame' of your game.