Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocompletion in dynamic language IDEs, specifically Python in PyDev

I'm new to Python, with a background in statically typed languages including lots and lots of Java.

I decided on PyDev in eclipse as an IDE after checking features/popularity etc.

I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after:

datafile = open(directory+"/"+account, 'r') datafile.

No useful methods are suggested (e.g. realines). Only things like call.

I am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'.

Is it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration!

Thanks,

like image 655
Greg Avatar asked Aug 14 '10 08:08

Greg


2 Answers

In my opinion, the Python shell is a much better place to explore new modules than relying on an IDE. Don't forget, in Python you can do anything in the shell that you can do in a program, because there's no separate compilation step. And in the shell, you can use dir(x) to find all the properties and methods of x, whether x is a module, a class, or whatever.

Even better, the enhanced iPython shell does provide tab completion for all objects.

In fact because of this, many Python programmers - myself included - don't use an IDE at all, but just a simple text editor (I use VIM).

like image 162
Daniel Roseman Avatar answered Oct 02 '22 19:10

Daniel Roseman


Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead)

like image 20
Tomasz J Kotarba Avatar answered Oct 02 '22 18:10

Tomasz J Kotarba