Netbeans Python IDE features: Configuring and Running Python Projects and Shortcuts

Sunday, February 15, 2009

In my previous post, we looked at the Netbeans IDE for python and jython, creating a new python project, settings and a high level overview of the IDE, in this article we will see in detail , the Netbeans CPython IDE features, the main reason why I am writing this is because I always wanted to have a quick reference on using the IDE features which I use extensively, sometimes its not easy to recollect IDE shortcuts if you are using many IDEs for projects involving different technologies, as is the case with me when I use the JCreator IDE for small java projects, most of the times I hit the walls on figuring out some project settings, command line options and other IDE configurations.

This writing may serve as a useful guide to Netbeans Python IDE users on some important shortcuts and project settings for CPython, for Netbeans users, this may be an easy transition, but for python users using IDLE for their projects, there are small changes in the way the similar shortcuts work in Netbeans.

Lets go to individual sections, in some sections I will be highlighting the differences between Netbeans Python IDE and IDLE features.

1. Python platform settings and running the interactive python console
2. Python Library Settings
3. Auto Completion feature for library and built in functions
4. Running Python projects and modules, configuring command line options
5. Important Python IDE Shortcuts

I assume that you know the basics features of Netbeans Python IDE, if not I recommend you to go through my introductory article on Netbeans Python IDE for Python and Jython.

1. Python platform settings and running the interactive python console

Now you have an active CPython project, the first thing you must always do is to change the Python Platform settings to CPython as shown in the figure below, note that right now this setting is not retained after you exit the IDE, but this may change in the later releases.

In Netbeans IDE, click Tools -> Python Platforms -> Select Python (2.5 in this example), and click "Make Default" button, note that Jython is the default platform used in Netbeans as its bundled with the Netbeans Python IDE.

Fig 1: Python Platform Settings

From the Netbeans python IDE, you can run the interactive python console (this is available on all python installations with the IDLE Python console), to invoke the python interactive console, all you need to do is to invoke Window -> PythonConsole as shown in the figure below.

Fig 2: Python Interactive Console

2. Python Library Settings

Python has its core libraries and third party libraries available through other python extension projects (lie PythonWin, SciPy, etc), all third party libraries are installed in /Lib/site-packages, you can view the standard python library search paths included by default (Tools -> Python Platforms -> Python Path) as shown below, you can also add your own library paths here where python can search for a module (Add -> Library Path).

Fig 3: Python Library Path Settings

3. Auto Completion feature for library and built in functions

Autocompletion is an important feature of any IDE, as obvious its supported for all libraries included in python search path as shown below, however a minor difference I noted is that it doesn't highlight this for built in python functions like type, str, etc (which IDLE does).

Fig 4: Python Auto Completion feature in Netbeans

4. Running Python projects and modules, configuring command line options

You can run a Python project (Main project source file) or an individual module using Run -> Run Project or Run File, but right now for individual python modules, this option is not included as a right click property, which Netbeans supports for java, though it should be available in future versions.

Fig 5: Running Python projects and modules

Command line options can be specified under Project Properties -> Run -> Application Arguments as shown below.

Fig 6: Specifying command line arguments for projects

5. Important Python IDE Shortcuts

Hope now you are excited about Netbeans python IDE and its features, if you use shortcuts frequently as I do for IDLE, then the following frequently used shortcuts will be handy.

1. Running a Python project - F6 (F5 in IDLE)
2. Running an individual python module - Shift + F6
3. Comment out Code Block - Ctrl + Shift + C
4. Indent Code Block - Alt + Shift + Right
5. Dedent Code Block - Alt + Shift + Left
6. Code Completion - Ctrl + Space

In the next post, we will see specific options and features available for JPython interpreter.

2 comments:

adhocboy@mac.com said...

Have you figured out how to add the python sqlite3 library?

Prasanna Seshadri said...

No, I haven't tried it.


Copyright © 2008 Prasanna Seshadri, www.prasannatech.net, All Rights Reserved.
No part of the content or this site may be reproduced without prior written permission of the author.