X

News, tips, partners, and perspectives for the Oracle Solaris operating system

NetBeans Python Editor

Guest Author

NetBeans 6.7, released earlier this summer, has a pretty nifty Python editor. To give it a spin a decided to set up a project for the Image Packaging System. If you want to try it yourself, here's the steps I took:

Install NetBeans

bleonard@os200906:~$ pfexec pkg install netbeans
DOWNLOAD PKGS FILES XFER (MB)
Completed 19/19 5638/5638 165.54/165.54
PHASE ACTIONS
Install Phase 6756/6756
Deleting content cache

Install the NetBeans Python Plugin

Start NetBeans (Applications > Developer Tools) and install the Python plugin (Tools > Plugins):

Create the IPS Project

The IPS Python sources are in /usr/lib/python2.4/vendor-packages/pkg, with the exception of the pkg script, which is in /usr/bin. To keep the NetBeans project simple, I copied the pkg script from /usr/bin to /usr/lib/python2.4/vendor-packages/pkg. I also renamed the script to pkg2.py. Adding the .py extension allows it to be recognized as a Python script by NetBeans. Changing the name to pkg2 prevents it from conflicting with the existing script in /usr/bin:

 pfexec cp /usr/bin/pkg /usr/lib/python2.4/vendor-packages/pkg/pkg2.py

In NetBeans select File > New Project and then select Python Project with Existing Sources:

Give the project a name such as PKG or IPS and set the Python Platform to Python 2.4.4:

Then add /usr/lib/python2.4/vendor-packages/pkg as a source root folder:

To give the project a quick test drive, right-click it and select Properties. Then set the Main Module to pkg2.py and the Application Arguments to something like 'info netbeans':

Then select Run > Run Main Project. You'll see the result in the Output window:

Editor Features

Now that we've got the project set up, let's look at some of the features provided by the editor.

Syntax Highlighting 

The code is easy to read.

Code completion

Ctrl+Space to activate.

Hover Documentation and Hyperlink Navigation

Holding down the control key and hovering over Classes and methods will also show you the documentation:

And clicking on the hyper-link will take you to the class or method.

Navigator Window

Also, the Navigator window is a quick way to find your way around a script:

Go to Type

And Go to Type (Ctrl + O) will quickly take you to any type:

Debugger

And finally, one of the coolest features is the debugger. Select Debug > Debug Main Project to start it:

Variables view:

You can find a summary of features on the NetBeans Python Wiki. Please file issues you find with the NetBeans Python Editor.


Join the discussion

Comments ( 2 )
  • Shmerl Thursday, September 10, 2009

    Is it also installable in Sun Studio?


  • Brian Leonard Friday, October 2, 2009

    There is an older Python plugin for Sun Studio, however, to get the features you see here you'll have to wait until the next release of Sun Studio, which is scheduled for mid-2010.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.