Search code examples
pythonpython-idle

IDLE autocomplete in a new file do not work


If I testing my codes on IDLE the autocomplete its works but if I open a new file don't.

See there pictures below:

  1. I just press CTRL + SPACE.

enter image description here

  1. So.. don't work in this case:

enter image description here

I'll think there are some configuration for solve this, any one knows?


Solution

  • Python idle doesn't work that way. You get autocomplete in idle shell because values are deduced in every run. When you use files your program is not evaluated until you run. Because you can assign any type to a variable at run time, there is no way for idle to confirm the type of variable.

    Understand with an example

    >> a = dict()
    >> a = set()
    >> a.  # <-- autocomplete knows type of a is set
    

    but the same code in a file

    a = dict()
    a = set()
    a. # <-- How does idle come to know what this variable is without running
    

    but when you run this file once your global variables will show autocomplete feature, but not the local scope variables.