What is the difference between a "source folder" and a "pydev package" in PyDev Eclipse?
To uninstall you should either go on and remove the org. python. pydev* from eclipse/plugins and eclipse/features or you can go to help > software updates > manage configuration, choose the PyDev plugin and disable it (after that, to completely remove it, you must restart Eclipse and only then select it for uninstall).
To switch to PyDev, if it isn't already selected, choose Window > Perspective > Open Perspective > Other > PyDev. Then, select the PyDev Package Explorer view by choosing Window > Show View > PyDev Package Explorer to see and access the contents of each project directory.
Go to Window → Open Perspective → Other and choose PyDev, then click OK. If you look at the upper right corner you will see that the perspective has changed from "Java" to "PyDev".
a package is a collector for files that have a logical grouping
import <package>.<file>
and a source folder makes the files directly importable
import <file>
and the regular folder is basically inaccessible.
I made a quick project that shows the differences. I put one file in each type of container: regular folder, package, and source folder. Each file had two items: a function called show() and a class with a single public member show()
I then put a driver file at the top level (in the project root, next to the 3 containers). This was just to try the different ways of importing things. Here is a copy of that driver file with comments to describe how the different elements are used:
### valid imports
import package
import package.file_in_package as thefileinpackage
import file_in_source
### invalid imports
#import package.file_in_package.packageclass #runtime ImportError
#import file_in_package #unresolved import
#import source #unresolved import
#import source.file_in_source #unresolved import
#import file_in_source.sourceclass #runtime ImportError
#import folder #unresolved import
#import file_in_folder #unresolved import
#import folder.file_in_folder #unresolved import
thefileinpackage.show()
packageclasss_inst = thefileinpackage.packageclass()
packageclasss_inst.show()
file_in_source.show()
sourceclass_inst = file_in_source.sourceclass()
sourceclass_inst.show()
package.file_in_package.show()
packageclass_inst2 = package.file_in_package.packageclass()
packageclass_inst2.show()
A "source folder" is a directory that contains source files. Putting .py files into this directory will make them discoverable by PyDev, so that you can for instance import them from other Python files.
A "PyDev Package" is a Python package. This means that it contains a file called __init__.py
. For example, if you create a new PyDev Package with name foo
, then you will get file foo/__init__.py
. You can place other .py files into foo/
, which you can then import. So, if you place bar.py
into foo/
, then you can do
import foo.bar
This is not possible with source folders.
You normally place packages into source folders. I don't know if it is possible to place a source folder into a package, but even if it were you would hardly ever do it.
A source folder is the folder which is added to the PYTHONPATH.
A package is a folder which has an __init__.py
file (and which is located beneath a source folder).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With