RSS

Search Engine

Wednesday, December 8, 2010

Your first Python program in Eclipse

Select File -> New -> Project. Select Pydev -> Pydev Project.

Create a new project with the name "de.vogella.python.first". Select Python version 2.6 and your interpreter.

Press finish.

Select Window->Open Perspective ->Other. Select the PyDev perspective.

Select the "src" folder of your project, right-click it and select New -> PyDev Modul. Create a module "FirstModule".

Create the following source code.

   
'''
Created on 18.06.2009

@author: Lars Vogel
'''
def add(a,b):
return a+b

def addFixedValue(a):
y = 5
return y +a

print add(1,2)
print addFixedValue(1)

Right-click your model and select Run As -> Python run.

Congratulations! You created your first (little) Python modul and ran it!

0 comments:

Post a Comment