Last Site Update: February 21st, 2024 | Latest Version: 12.0.0


Main

Download

Screenshots

Manual

Developers

About/Contact


PyDev LiClipse




Previous (Project Configuration) Root Next (Running a Program)


Creating our first module (now that the interpreter and the project are already configured).

To make things easier, make sure that you are in the PyDev perspective – it is automatically opened when you create a PyDev project, but just in case, you can open it by going to the menu: Window > Perspective > Open Perspective > Other ... > PyDev, as pointed in the picture below.


A perspective defines what appears in your window and which actions are enabled... If you want to add something (as a menu or action), you can go to the menu: Window > Perspective > Customize Perspective .... To create our first module, we will use the default PyDev perspective, as it already has the wizard shortcuts pre-defined in the File > New menu

First, we will start creating a new package in a project named 'test' (it was created with the default 'src' folder, and all the code should be put underneath it).

So, let the 'src' folder selected and go to the menu: File > New > PyDev package (or Alt+Shift+N, A) and fill the package name as below (the source folder should be automatically filled)..


If everything goes ok, the structure below will be created (and the file /root/nested/__init__.py will be opened).

Note: Check to see if the 'P' icon is appearing for your items (as in the picture below) and in the top of your editor after opening it. If it's not appearing, it may be that there's a problem with the file association, so, go to Window > Preferences > General > Editors > File Associations and make sure that the .py files are associated with the Python Editor (note that because of an eclipse bug, if it seems correct, you may have to remove the association and add it again)


Now, let's create the example module. Select the folder /root/nested and go to the menu: File > New > PyDev module (or Alt+Shift+N, M) and fill the module name as below (again, the other fields should be automatically filled).


After you press Finish, a new dialog with which module template should be used to create the module will be shown (and the Config available templates... link in the dialog can take you to the place where you can add/remove/edit those - which are the templates under the New Module context.


The file /root/nested/example.py should have been created, so, to finish this example, in the empty file, press Ctrl+Space (that's the shortcut for the PyDev code-completion). Once you do that, the 'context-sensitive' completions should appear (as below).


NOTE: If the code-completion does not work, see the FAQ on the topic.

NOTE FOR JYTHON USERS: If you are in jython, the first activation might take a while. This usually happens when jython has to do the processing of new jars. The next time you start it, if it takes the same time, it could be that your jython 'cache-dir' is not writable, so, you can create a script with the code below to see where is the cache dir and check its permissions (or if there is no permission problem, you can try deleting the dir and seeing if it gets correctly recreated in the next jython activation).

Code:

import sys

print(sys.cachedir)





Previous (Project Configuration) Root Next (Running a Program)

PyDev development

PyDev is open source and depends on your contributions! This may be in the form of bug fixes, answers on stackoverflow, new features...

Another option is financially supporting it at: Patreon (which provides a way to support it monthly and get rewards starting with $1).



Or through 1-time contributions at:

  Paypal




Search PyDev-related content







Copyright: Brainwy Software Ltda, 2014-2021