Autocompletion in dynamic language IDEs, specifically Python in PyDev

前端 未结 7 1715
无人共我
无人共我 2021-01-14 01:53

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/

相关标签:
7条回答
  • 2021-01-14 02:15

    You might want to take a look at WingIDE. It autocompletes your datafile correctly.

    If it is unable to infer the type, you can use an assert like

    assert isinstance(datafile, file)
    

    to help the autocompleter out

    0 讨论(0)
  • 2021-01-14 02:19

    Someone more knowledgeable here can give you a detailed answer. Here is a short one.

    Autocomplete for a dynamically typed language can by nature never be as rich as that for a statically typed language. In the case of open for instance there is no way to figure out what will be the return type at the time of writing the code. The method signature does not include a return type unlike a statically typed language like Java. Consequently the IDE is not able to give you any hints.

    You certainly should have an REPL running during any Python development. One advantage of an interpreted language is that you can test small chunks of your code on the REPL as you go along. It is also a good place to test your understanding of how built-ins and other modules work.

    I work on Ubuntu so I do not know how easy or difficult it is to get IDLE running on a Mac. I usually work with the very handy iPython for REPL needs and use Pydev for other development (such as Django). You might want to give iPython a try.

    0 讨论(0)
  • 2021-01-14 02:29

    You want IPython. As Daniel pointed out above, the interactive shell is a much better way to explore Python (and indeed, most other languages too).

    This might help with setting it up on OSX.

    0 讨论(0)
  • 2021-01-14 02:31

    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).

    0 讨论(0)
  • 2021-01-14 02:34

    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)

    0 讨论(0)
  • 2021-01-14 02:34

    I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules

    I use ipython. Ipython is an enhanced version of the interactive shell that adds tab completion and quick access to an object's doctstring. It also gives lots of other features that the standard shell does not have - you can find a summary of its features here.

    0 讨论(0)
提交回复
热议问题