19

IDLE is being very dodgy as to when it will actually show an Auto-complete menu. As of late it hasn't been working at all, or, more specifically, only works during an interactive session.

I've been using Code Blocks for C, and have gotten really used to the very nice auto-complete features, so it's a bit frustrating not having them -- especially while trying to learn a new frame work and what class is associated with which methods, etc, etc..

Is there an easy fix to get IDLE auto-complete working again? I'm using python version 2.7.

Is there perhaps a simple editor I should look into? I've tried Vim, which was a little too heavy for my simple needs, Ninja, which I couldn't get to work for anything, and Sublime text 2, which I couldn't get my wxpython stuff to play with. What would a nice option be? Anything similar to Code Blocks would be cool, although, I'd be perfectly happy with IDLE if it would consistently work!

REQUESTED CLARIFICATION: OK, so it seems I may have some of my terminology backwards. By non-interactive, I mean, for instance, right clicking on a python file and selecting "edit with IDLE". This brings up what I guess could be described as a text editor. You can enter all you code here. Once ready, you then hit F5, or select Run, and it launches (what I've been referring to as) the interactive terminal. It's here that you can type in code, press return, and instantly have that code evaluated.

What my question is referring to it the former, the part of IDLE where you edit the code. Sometimes while typing, after a . it will display the available methods, or after an open parenthesis it'll give hints as to the values expected. but the thing is, sometimes it does these things, sometimes it doesn't.

ctrl-alt-delor
  • 7,506
  • 5
  • 40
  • 52
Zack
  • 4,177
  • 8
  • 34
  • 52
  • http://ipython.org/ with vim or even simply gedit – wim Feb 01 '12 at 01:27
  • @wim Sorry, I may have explained it badly in my post, but the issue is that auto-complete does work interactively, but *only* interactively. If I'm just typing away in IDLE auto-complete doesn't work. So I'm trying to figure out how to make it work when coding *non*-interactively. – Zack Feb 01 '12 at 01:29
  • 3
    Oh right, sorry! I haven't found any need for an IDE when working in python, so can't help you there. – wim Feb 01 '12 at 01:32
  • Are you sure that this ever worked non-interactively? – Winston Ewert Feb 01 '12 at 01:53
  • "only works during an interactive session"? How else can you use IDLE? It's an interactive tool, right? What is a non-iteractive "session" with IDLE? Running a script? This makes very little sense. Can you **update** the question with an explanation. – S.Lott Feb 01 '12 at 01:57
  • @S.Lott I've added a bit of clarification to the main question. I may be using the terms incorrectly as I'm still a touch of a newbie... – Zack Feb 01 '12 at 02:07
  • If you're looking for a IDE for Python, please read this: http://stackoverflow.com/questions/81584/what-ide-to-use-for-python – S.Lott Feb 01 '12 at 03:13
  • Please don't **add** a "Requested Clarification". Please rewrite the question to make sense. The "edit mode" doesn't (and can't easily do) code completion. This isn't news or a problem, it's a consequence of a dynamic language. Please simplify the question to say **exactly** what's going on. "This brings up what I guess could be describes as a text editor". No. It's not what "could be described as..." It **is** a text editor. Simplify. Focus. Clarify. – S.Lott Feb 01 '12 at 03:15

5 Answers5

15

The only thing i found so far is that if an editing session of IDLE is connected with python shell (called "interactive mode" in the question, i.e. after an attempt to run the edited script) then "non-interactive" IDLE can autocomplete based on values in interactive window. For example, if I type

a = [];
a.appen

and then hit < Tab > it will do nothing, but if I previously type

a = []

in corresponding python shell, IDLE will autocomplete correctly.

So my only suggestion is import same modules with same names in python shell window in order to make them "visible" for non-interactive IDLE editor.

sukhmel
  • 1,402
  • 16
  • 29
  • 1
    This works even if your script is incomplete (produces errors when run). Thanks for the tip. Unfortunately, you'd have to run your code various times as you build out the script to get this. This will, however, be more useful as your code gets longer. In longer code, you'll tend to use previously defined variables (that you tested with F5) and thus more things available under auto-complete. – VISQL May 18 '17 at 17:07
12

I had the same problem with IDLE, because I want to learn Qt and therefore autocompletion is very useful.

As it says in the settings of IDLE, you can trigger the autocomplete with "Control + Space", e.g. after a "QtGui.". Then a menu opens where you can arrow-scroll through the entries.

ctrl-alt-delor
  • 7,506
  • 5
  • 40
  • 52
user2366975
  • 4,350
  • 9
  • 47
  • 87
  • 2
    I can't vote up yet, but thank you user2366975! Using Ctrl + Space works like a charm. IDLE is quite fast under windows, but on my Mac it was taking forever to give me options to autocomplete. Good bye TextWrangler, I'll be using IDLE again. – VDubs May 27 '13 at 17:41
  • So in order for autocomplete to work, you need the shell to import a library first. Then the autocomplete will offer functions/classes (after ctr+space) and tab. – icypy Jan 03 '18 at 00:39
3

using the 'IDLE Editor window', you need to save and execute your code first. The application running, turn back to the Editor window to use the auto-completion.

Leo Piva
  • 41
  • 1
  • That's correct, but question is already answered in the same manner, no sense in repeating it six years later. – sukhmel Jul 18 '18 at 01:46
2

Sometimes it has to do with the time you have to wait to get a suggestions.

When you go to options > extensions > general at completions popup wait you can change it to about 500ms. In my case it was 2000ms by default.

FuruiTatsu
  • 71
  • 10
1

In my case, I had to open Options menu -> Extensions tab on the editor and look to make sure AutoComplete and other relevant options were enabled. They actually were, but by just clicking on 'Apply' even though I dint have to change anything did the trick for me.

Vijayanand Settin
  • 826
  • 11
  • 13