Blankman
Blankman

Reputation: 267390

Python IDE that you can highlight a method/class and jump to its definition

I'm trying to use textmate, but I find it hard to navigate a project with it.

I admit I probably just don't know the the IDE well enough.

Is it possible to highlight a class or method and jump to its definition?

Upvotes: 3

Views: 2978

Answers (9)

Mihnea Giurgea
Mihnea Giurgea

Reputation: 447

Here's a small Bundle/Command for TextMate that can accomplish Python Jump to definition for 99% of cases:

FUNC="$TM_CURRENT_WORD"
DIR="$TM_PROJECT_DIRECTORY"
OUTPUT=''

# Define the class or function definition string that we're looking for.
FUNCDEF='(def|class) '$FUNC

# Find all files that contain FUNCDEF
FILES=(`egrep "$FUNCDEF" $DIR/* -r -l --include=*.py`)

#
# Look for a function declaration within a files contents.
#
# <file>
#
function lookup_function {
    local line=`nl -b a "$1" | egrep "$FUNCDEF" | awk '{print $1}'`
    if [[ "$line" -gt 0 ]]; then
      # echo 'Jumping to --> '$1':'$line
      mate "$1" -l "$line"
      exit 0
    fi
}

# Iterate files
for file in ${FILES[@]}; do
    echo $file
    lookup_function "$file"
done

# Nothing found
echo 'Function '${FUNC}' was not found within the current project.'

Upvotes: 0

david.barkhuizen
david.barkhuizen

Reputation: 5675

Aptana Studio 3.0

The PyDev team is now operating under the auspices of Aptana, which makes Aptana Studio 3 - an Eclipse customisation - preferable to the 2-step process of first downloading Eclipse, and then installing the PyDev extension.

Aptana comes pre-configured for Python (and others), and in addition features custom support for Django projects [including JavaScript support].

The product is fast and responsive, and features powerful meta-level functionality such as jumping to the definition of a callable, deducing object fields from init initialisation, module browsing, very good code completion, and more...

Thus far, out of Eclipse+PyDev, NetBeans Python Edition and Aptana Studio 3, based on relatively extensive personal testing, AS3 wins hands down.

Upvotes: 0

Jody
Jody

Reputation: 8301

I'm a fan of pyscripter http://code.google.com/p/pyscripter/. Has those features and more (and a regex checker!)

Open source of course.

Upvotes: 0

Robert Roos
Robert Roos

Reputation: 111

I too have been looking for an IDE that makes this sort of thing easy.

About two hours ago I downloaded Pycharm and it has blown me away. This may be the coolest IDE I have ever used, for any language. So far it seems to do everything that big IDEs like VisualStudio or Eclipse do (for many languages), only without the learning curve or resource consumption of those monsters.

It does exactly what you are asking... just right-click on any class, or a method, or pretty much anything else, Select "Go to Implementation" (or Declaration), and up it pops in a new tab.

So many other amazing slick features too... just try it!

There's a 30 day trial and after that it's pretty reasonable (like $29 for academic, $100 for individual, and $200 for a commercial team. Oh and FREE if you have a bona fide OpenSource project that's been actively worked on for at least 3 months.)

(I apologize if this sounds like an advertisement. I can assure you that it's not. I'm just kind of... obsessive... about IDEs, and very frustrated that so few of them meet my standards. I will revise this if I find any "caveats" but so far, so good.)

Upvotes: 1

Ryan Jenkins
Ryan Jenkins

Reputation: 967

I'm not sure about what functionality is available in textmate but would a simple search work? i.e. Ctrl+F with the query "def function" including the def part so you find the definition instead of a call?

Upvotes: 0

user349594
user349594

Reputation:

WingIDE if you can fork out some cash will do what you want all bundled up and with little to no configuration effort. Otherwise Eclipse with Aptana's pydev is free, and does exactly that, plus a lot more (ctrl+click pretty much anything for redirection and a lot of other useful things like pyc removal etc.).

Navigation problems though are usually symptomatic of more than just lack of tools. A decent structure to your projects and a version control system (even if you work locally and solo) would go a long way helping to address that.

Upvotes: 0

Adrian Heilbut
Adrian Heilbut

Reputation: 103

Wing IDE is an excellent IDE for python.

Upvotes: 1

Brian S
Brian S

Reputation: 5056

If you're asking about IntelliJ IDEA, Python is only available for the commercial version.

If you're asking about a Python IDE, IDLE comes with Python already. I can also recommend Boa Constructor.

Upvotes: 0

Krumelur
Krumelur

Reputation: 32597

I am not sure that I understood you question, but if you look for an IDE for Python I would strongly recommand you have a look at PyDev

It's by far the most feature-rich IDE for Python and it has a really active development team. And did I mention it's free and open source?

Upvotes: 5

Related Questions