john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

project package modules classes unit tests

Windows -> Preferences -> PyDev -> Editor -> Code Style -> Code Formatter (checkboxes for spaces before and after)


A package is simply a directory with an __init__.py file inside it. For example:

mypackage/__init__.py <-- this is what tells Python to treat this directory as a package


A Python module is simply a Python source file, which can expose classes, functions and global variables
Modules should have short, all-lowercase names.


from mypackage.mymodule import myclass


ExamplePython (Project)
|
src -> ExamplePython (Package) -> roman.py
|           |
|           -> __init__.py
|
test -> ExamplePython (Package) -> romantest.py
|           |
|           -> __init__.py



To run the unit tests:
Control + F11 -> unittest


Control + Alt + Enter (when the roman.py file is selected) will open an interactive console
    toRoman( 5 )
    'V'


INCOMPLETE:
OR cd \workspace\ExamplePython\src (project) ... python
>>> from ExamplePython import roman  ?

  • « maven version number variable in manifest
  • unittest roman.py »

Published

Dec 21, 2012

Category

python

~129 words

Tags

  • classes 92
  • modules 2
  • package 3
  • project 4
  • python 180
  • tests 5
  • unit 3