Using Eclipse with Python
These are some notes about my experiences of using Eclipse with Python
(From memory - details not confirmed)
This describes my working environment, which is based on Windows XP. (OK, that's not OS, but I have too much invested in this platform to change right now...)
- Install Python 2.4.1
- Instralled Eclipse 3.2
Installed PyDev plugin 0.9.8.3
Create new project (File -> New -> Project -> General -> Project)
In Project -> Properties -> PyDev project type, select project type from available Python installations (NOTE: also supporrts Jython)
In Project -> Properties -> PyDev PYTHONPATH, create (or check) Python source path
I'm currently using a directory layout that is modelled on that created by Maven 2 for Java projects:
+--src/ | +--main/ | | +--python/ | | | : | | +--resources/ | | : : | | | +--test/ | +--python/ | | : | +--resources/ | : : | +--target/ : (etc.)
Within Eclipse, the Pydev editor provides various helpers and on-the-fly syntax error detection when editing Python code in .py files.
PyDev does provide a debugger, but I haven't used that yet. I prefer to organize my development around unit testing.
2. Unit Testing
PyDev contains a test runner facility that works in conjunction with the standard unit testing framework. (That is, standard with Python 2.3 and later, available as a library with earlier versions.) But getting the unit test runner to work can be confusing.
A reasonable approach would be to select the test suite main program and then select (Run -> Run as -> Python unit test). No dice. In this case, select (Run -> Run as -> Python run), and the unit tests results are displayed in a console window.
The built-in test runner works by selecting a directory containing the unit test modules in the package explorer window, and then selecting (Run -> Run as -> Python unit test). This causes PyDev to search source modules in this directory (and subdirectories?) for test cases - class methods having names that start with "test", assemles those into a test suite, then runs that test suite. This would seem to allow test code to be written as-needed, maybe even in the module under test, and have the Eclipse run-time seek out and run those test cases.
http://www-128.ibm.com/developerworks/opensource/library/os-ecant/ - Python development with Eclipse and Ant
http://wiki.python.org/jython/JythonDeveloperGuide/EclipseNotes - Some notes about using Eclipse with Jython
-- GrahamKlyne 2005-10-28 13:26:00