Python in NetBeans

For the past few weeks I’ve been using the NetBeans (with the new Python module) as my primary IDE.  I generally use TextMate, which is more than an editor and less than the kitchen sink, lying somewhere between BBEdit and Emacs.  TextMate is fast and a pleasure to use, but lately I have found myself in need of something a little more robust.

Back in October of 2007, I wrote an article on Java.  I used NetBeans exclusively during the project about which the article is written and found it to be a solid, well-thought out application.  It is reasonably fast and “feels good” to use, which is something I feel most Java applications lack.  It has its problems; in particular, it is not nearly so easy to add language support to NetBeans as it is to TextMate or JEdit.  However, it is beginning to build a decent set of language support plugins and supports most of the languages I use in development: Python, PHP, and Javascript.  It even has support for several of the more popular JS frameworks, including Prototype/Scriptaculous and JQuery (both of which I regularly use).

My first impression is good.  The Python support is very nice.  It has a few problems guessing at types, which is annoying if you leave auto-hinting enabled, and it does not know about the with_statement (which it believes to be an unused import).  Aside from that, it does a good job with hinting, although that is not a feature I particularly need or want, and it manages imports well, removing unused ones and reordering them.

The versioning system integration is good, too, and sheds a few clicks from my life.  It is annoying to need a wizard to create a blank file, though.  I do get a lot of use out of NetBeans’ code checking.  In a mature product, it is easy to end up with a lot of unused variables as code gets added and removed.  The refactoring features are simply a blessing, as anyone who has had to go through several dozen files to make a critical API update can tell you.

One other nice feature that is not immediately apparent is intelligent undo.  I know it’s not a big deal, but it’s the little things that give a product its luster.

Most of these features are, in fact, available in a nice little editor written in Python named .  But Editra’s graphics (using wxwidgets) are slow and I don’t have the patience for an editor that does visibly jerks while updating the screen.  I think that I will use NetBeans for now.

Update: Shannon -jj Behrens wrote another good review of Python in Netbeans on his blog (jjinux.blogspot.com).

Leave a comment | Trackback
Dec 13th, 2008 | Posted in Programming
Tags: ,
  1. Dec 14th, 2008 at 16:14 | #1

    I’ve been using it for python as well, for the past week and I must say I’m impressed! I dwelled in Eclipse + Pydev for a while, but it just doesn’t feel all that great.

    I preffered Netbeans for java already and i’m growing to love it for python as well.

  2. Jeff
    Dec 14th, 2008 at 19:11 | #2

    I have never liked eclipse. I feels clunky and the preferences are confusing. I end up spending as much time trying to figure out where to set a preference than I do programming.

  3. Dec 19th, 2008 at 13:05 | #3

    Hi Jeff,
    Can you provide some details on what was broken? I don’t think we have any bug reports on this specific issue (the with-statement auto hinting problem you’re referring to). And yes, the type inference still needs some work.

  4. Jeff
    Dec 19th, 2008 at 14:43 | #4

    Most importantly (to me, anyway) is that ‘from __future__ import with_statement’ is seen as an unused import.

  5. Dec 20th, 2008 at 16:23 | #5

    Thanks Jeff. I’ve fixed this now (along with better code completion for future imports) in the 7.0 builds (available in build #413 and later from http://deadlock.netbeans.org/hudson/job/python/ )

    – Tor

  6. Jeff
    Dec 22nd, 2008 at 10:13 | #6

    One other bug is that the color settings for Python do not save in a custom profile.

  7. Dec 24th, 2008 at 08:19 | #7

    Found another small issue. By convention, an underscore is used to assign a throw-away value when necessary. For example, when only the tail of a tuple is needed:

    _, a, b = (1, 2, 3)

    In this case, the underscore is identified as an unused variable in netbeans.

    Also, Tor, is there some better place I should use to report bugs?

  8. Dec 27th, 2008 at 14:05 | #8

    Hi Jeff,
    I’ve fixed the underscore issue recently (in the 7.0 builds, not in the 6.5 early access). The unused detector is more configurable now; for example, you can set it to ignore unused tuple values in assignments (since you often don’t have a choice but to specify something there), as well as some other things. Similarly, the name rule hint is also much more flexible. There are various other new features too (such as code coverage – see http://blogs.sun.com/tor/entry/netbeans_screenshot_of_the_week6 ) and a new test runner, so if you’re using the Python functionality you’ll probably want the new bits.

    I’m not sure what you mean by the color settings / custom profile issue…

    For reporting bugs, the best place is the NetBeans issue tracker – e.g. file here – but that registers a (free) login etc. You can also write to our mail alias – .

  9. Dec 27th, 2008 at 14:06 | #9

    (By the way, to configure the hints, go to options > Editor > Hints > Python > choose the hint to configure, such as the unused detector. As you can see that are some additional hints not yet enabled by default – such as the unresolved detector.

  10. Jeff
    Dec 29th, 2008 at 09:52 | #10

    The color settings for python-specific tokens do not persist after closing the IDE. Specifically, when I choose a color scheme using a dark background, I need to change the `mark-occurrences` label to a darker background color, since by default is khaki, and white text is hard to read on it. This change is not saved between sessions.

  11. Dec 29th, 2008 at 17:21 | #11

    Ah. Dark color themes. I had forgotten about those. I’ve gone and fixed those now such that out of the box, the 2 bundled dark color themes should look good for Python (e.g. already have appropriate colors for mark occurrences, as well as the code coverage highlights etc). This is in build #4704 and later from http://deadlock.netbeans.org/hudson/job/trunk/ .

  12. Jeff
    Dec 31st, 2008 at 13:45 | #12

    Looks good, Tor. I just sent an additional email to the netbeans.org address about decorators.

  13. Jan 5th, 2009 at 13:04 | #13

    Hi Jeff,
    it doesn’t look like your e-mail made it through; I haven’t seen anything on the aliases. E-mails to the alias from non-subscribers usually go to the moderator queue, but I haven’t seen it so I’ve contacted the infrastructure owners to see what is going on with the moderator queue (we recently switched over from a different e-mail alias setup).

    In the meantime – since you mentioned decorators: Was your problem that the semantic highlighting of function names get messed up when there are Python decorators present? If so – I’ve been aware of (and just now fixed, upcoming build 520) that problem. If there is something else, can you paste in your e-mail here in the meantime until the alias issue is resolved?

    – Tor

  14. Jeff
    Jan 5th, 2009 at 16:40 | #14

    Tor,

    I put in a ticket for it: http://www.netbeans.org/issues/show_bug.cgi?id=156228. It is the actual decoration (e.g. @foobar) that is getting highlighted incorrectly. Some characters in the decorator are being bolded, some are not.