Python Forum
data input while debugging causes unwanted code completion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
data input while debugging causes unwanted code completion
#1
I am a relatively inexperienced coder running python 3.13 using PyCharm 2025.1.3.1 (Community Edition). I am debugging the following code:
def name (): text = input ('\n Enter your name: ') print(text) name()
When I run this, it behaves as expected, but when I debug it and respond to the prompt with 'fred' I get code completion candidates as I type and when I hit enter after typing 'fred', I get the following.

Enter your name:
>? from platform import freedesktop_os_release
>?
>? freedesktop_os_release()

Continuing debugging does not print 'fred' but code that follows executes as expected (the name data is not available). I can prevent this behavior by entering a space after entering the letter 'd' . I think this is a bug.
Reply
#2
Along with Python you get a simple Python IDE called Idle, free of charge. Profis don't like Idle too much, but I find it works well for me. Try using Idle, at least for very simple stuff.

If something does not work, Idle will print a red message, telling you what went wrong. An example:

Note: the variable text is not defined in the function get_name(), so we get an error when you try and use the function get_name() in Idle:

def get_name (): name = input ('Please enter your name: ') print(f'Your name is {text}. Hi {text}!') return name name = get_name()
You will see this output in Idle:

Output:
Please enter your name: Fred Dref Flintstone Esquire Traceback (most recent call last): File "/usr/lib/python3.12/idlelib/run.py", line 580, in runcode exec(code, self.locals) File "<pyshell#12>", line 1, in <module> File "<pyshell#11>", line 3, in get_name NameError: name 'text' is not defined. Did you mean: 'next'?
So now you can go back and fix the error.
Reply
#3
Appending the space to your input caused the input to have no autocomplete matches. If you want to stop pycharm being helpful, press the escape key to exit out of the autocomplete.

Pycharm is not a great tool for debugging a script. It likes to work with projects. Working on single files is not what it's designed for. VSCode it more flexible, working well with projects and single files. But it is less "helpful" than pycharm, leaving it up to you to create virtual environments.

IDLE has its own quirks. The tools are quite primitive, and it has a nasty habit of running code differently in the IDLE interpreter than the same code runs using python from the command line.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Debugging live plotting data Nietzsche 1 1,723 Mar-12-2025, 03:50 AM
Last Post: Tishat73
  How to remove unwanted images and tables from a Word file using Python? rownong 2 2,133 Feb-04-2025, 08:30 AM
Last Post: Pedroski55
  Python: How to import data from txt, instead of running the data from the code? Melcu54 1 1,304 Dec-13-2024, 06:50 AM
Last Post: Gribouillis
  I think I need to delete input data because returning to start fails thelad 2 1,670 Sep-24-2024, 10:12 AM
Last Post: thelad
  Code Completion in Visual Studio for External Libraries mjakov 0 1,253 Aug-25-2024, 02:48 PM
Last Post: mjakov
  Help with to check an Input list data with a data read from an external source sacharyya 3 2,614 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  manually input data jpatierno 0 1,157 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Input network device connection info from data file edroche3rd 6 4,020 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
Question in this code, I input Key_word, it can not find although all data was exact Help me! duchien04x4 3 2,818 Aug-31-2023, 05:36 PM
Last Post: deanhystad
Question Unwanted execution of unittest ThomasFab 9 6,176 Nov-15-2022, 05:33 PM
Last Post: snippsat

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.