kevinjosethomas/py-mon

Issue with Input Handling in PyMon

Closed this issue · 3 comments

Code

age = input("Enter your age: ")
age_input = int(age)
print("Your age is:", age_input)

day = input("Enter the day of the week: ")

Description

When running Python scripts within the PyMon environment, I encountered an issue related to user input handling. After entering the age as prompted, pressing Enter causes the cursor to move to the next line without displaying the prompt for entering the day of the week. Subsequently, when re-entering the age, the script throws a ValueError, as shown below:

Traceback (most recent call last):
  File "C:\Users\....", line 2, in <module>
    age_input = int(age)
ValueError: invalid literal for int() with base 10: ''

This behavior makes it difficult to proceed with the script execution as expected.

Steps to Reproduce:

  • Run a Python script within the PyMon environment.
  • When prompted to enter the age, input a value and press Enter.
  • Notice that the cursor moves to the next line without displaying the prompt for entering the day of the week.
  • Again press enter when prompted (if applicable).
  • Observe the ValueError thrown by the script.

Expected Behavior:

After entering the age and pressing Enter, the prompt for entering the day of the week should be displayed, allowing the user to continue providing input as expected.

Additional Information:

  • PyMon version: 2.0.4
  • Python version: 3.9.4
  • Operating system: Windows

This issue significantly affects the usability of the PyMon environment, especially for scripts requiring user input at multiple points. Any guidance or workaround for addressing this issue would be greatly appreciated.

Hey, thanks for reporting this! You can work around this by hitting enter when it asks for input, and then entering the input before hitting enter again. It would look like this:
image

My best guess is that this is because pymon is constantly checking for input itself (to see if the user enters rs or stop) which seems to be causing issues with the input handler in your program. Let me know if the workaround works for you. I'm not sure how else I could implement the rs and stop commands but I can add an argument that doesn't check for them if the workaround doesn't work for you.

Thank You

Just wanted to let you know, with version 2.0.5, pymon now has a -c flag that runs it in clean mode. This should fix all input errors and also remove all additional pymon logging.