192

A Python module is simply a Python source file, which can expose classes, functions and global variables. When imported from another Python source file, the file name is treated as a namespace. A Python package is simply a directory of Python module(s). For example, imagine the following directory tree in /usr/lib/python/site-packages: mypackage/__init__....


121

An important point missing from the other answers: Using a package manager means having a configuration that indicates which library versions you are using and makes sure that config information is actually correct. Knowing which libraries you use, and which version, is very important if you: need to update a library due to a critical bug / security hole; ...


67

Folder-by-type only works on small-scale projects. Folder-by-feature is superior in the majority of cases. Folder-by-type is ok when you only have a small number of files (under 10 per type lets say). As soon as you get multiple components in your project, all with multiple files of the same type, it gets very hard to find the actual file you are looking ...


39

Pros of lib folder disappear quickly after you move from small scale development to bigger work. For example the "benefit" of not requiring an external tool is trumped by the work required to manually manage your dependencies, so the tool will be you (in more than one sense of the world). You don't need an internet connection for a package manager. You can ...


34

You're missing many of the advantages of package managers. Package managers allow you to avoid checking large (several megabyte or larger) binaries into source control. Doing so is anathema to many source control tools, the pervasive git being one of them. We had a repository hit Bit Bucket's size limits a couple months ago because developers were checking ...


31

To answer the question in the heading: tar.gz/tar.bz2 became the standard for distributing Linux source code a very very very long time ago, as in well over 2 decades, and probably a couple more. Significantly before Linux even came into existence. In fact, tar stands for (t)ape (ar)chive. Think reel hard, and you'll get an idea how old it is. ba-dum-bump. ...


28

Actually some people (of noticeable boost fame) are working hard to create and establish such a system called Ryppl. It is hard to establish such a System for C++, because it has no single player which can dictate it. --UPDATE: Unfortunately it is abandonned. On your second question, a normal package manager (besides not being cross platform) does not ...


25

This really has nothing to do with the technology in question, unless you use a framework that forces folder-by-type on you as part of a convention-over-configuration approach. Personally, I am strongly of the opinion, that folder-by-feature is far superior and should be used everywhere as much as possible. It groups together classes that actually work ...


24

One way I know to get such information is by using PowerShell in the Package Manager Console, from within Visual Studio. The Package Manager Console is a PowerShell console within Visual Studio used to interact with NuGet and automate Visual Studio. Basically you can use the Get-Package cmdlet to get a list of packages referenced in a specific project (...


23

Java tutorials > Learning the Java Language > Packages: For convenience, the Java compiler automatically imports three entire packages for each source file: (1) the package with no name, (2) the java.lang package, and (3) the current package (the package for the current file)... Class String is in java.lang package, hence it is imported automatically per ...


22

As explained in its javadoc, the purpose of Iterable is to support particular language syntax: Implementing this interface allows an object to be the target of the "foreach" statement As such, it belongs to the lang package, which Provides classes that are fundamental to the design of the Java programming language. Other classes at the diagram belong ...


21

The concept of a module is different from the instantiation of that concept. Java has always had modules. A method is a module, so is a class and so is a package. A module is a unit of organisation in which internal details are hidden, and that communicates with other modules via agreed contracts. For example, a method is a module because it has hidden ...


19

I have created several PHP web applications that I distribute (internally) through Debian packages. Doing so has been straightforward thanks to scripts (simplified here) to automate the process: create_package.sh: # create a clean debian package directory rm -rf debian mkdir -p debian/DEBIAN mkdir -p debian/var/www/myapp # populate the debian directory cp ...


17

I think that a problem with C and even more with C++ is that they are more heterogeneous languages: even though these languages are standardized there exist different compilers with different options or different sets of supported features. E.g., I remember posting a question about C++ on stack overflow with an example that was working perfectly on GCC / ...


17

You do the simplest thing that works for you. For a one function module, there is absolutely no point in creating a package. Packages are useful for creating an additional namespace and/or for organising your code across multiple modules. The json and unittest modules in the Python standard library are really packages for example, for code organisation ...


17

Working with packages-by-feature stands out in high modularity and cohesion. It allows us to play with the components' scope. For example, we can use the access modifiers to enforce LoD and the dependency inversion for integrations or/and extensions. Other reasons are: Easier code navigation A higher level of abstraction Minimize scopes (bounding contexts)...


16

I don't know about when, but I imagine the reason why it's used is a combination of: tar being traditional (it's very old); easy management from a command line; tar preserving file system info that ZIP or RAR may not; and the two pass process means that compression is more efficient (one big file compressing better than many little files). bzip2 (.bz2) ...


16

Having recently converted our product from using manually downloaded libraries to automatic package management with Nuget, I can say that using a package manager has massive benefits. Our product is implemented across 27 C# projects, which is relatively small by today's standards. Some of our third party dependencies have dozens of assemblies. Prior to ...


14

Global uniqueness. If everyone, or at least serious developers who distribute their code beyond in-house projects, adheres to that convention, it will never happen that you get name clashes when you add another third-party library to your project. Bear in mind that Java was initially propagated as a solution for code deployment anywhere, anytime (via applets ...


14

The difference is slight, but consistent. Transforming a representation into another one involves taking the same data and expressing it in another format - for instance, a hexadecimal into a decimal number, or mixed-case strings to an all-lower string. Typically, you need nothing but a fixed set of rules to carry out such a transformation. Resolving a ...


14

No need of external tool to manage packages That's kind of a non-point is it? If I use a package manager, I don't need to have a lib folder. I also don't have to manage the packages myself. No internet connection required to build Aside from that not having an internet connection today while developing is somewhat rare (maybe with the exception of being ...


12

As Wikipedia says on the subject, "The Java Language Specification establishes package naming conventions to avoid the possibility of two published packages having the same name."


12

I've been involved in projects like this twice now (both using nuget with .NET), and I would say that on balance it is a good idea. But your mileage may vary. Don't think for a minute that it's a panacea, that it's going to solve all of your problems without causing new ones. Release management will gain a whole new layer of complexity, you'll need to deal ...


11

The problem with trying to put each class in a package which has a semantically correct name for that class is that it tends to lead to packages that contain very few classes, or sometimes even just one class. This in turn leads to a multitude of packages. A more pragmatic approach to package naming is to simply help you find stuff. Keeping frequently ...


10

Your profile on Software Engineering implies that you control petr.pudlak.name, which gives name.pudlak.petr.exampleproject as a possibility. Another technique to ensure uniqueness is to base it on the means through which the program is distributed to the public. If the username associated with your GitHub repositories is petrpudlak, something like com....


10

When I need to use two different classes with the same name or the codebase I'm writing for often utilizes classes with the same names (which can happen if the classes are from different packages). This isn't such a rare conflict to happen: java.util.Date java.sql.Date I can't tell you how many classes I've come across called "Document" Keep in mind in ...


10

Let me hazard at an answer, though much of it may be assumptions/splitting hairs/ranting, etc. Are they the same thing? Well, yes and no From this JavaWorld article about "Modularity in Java 9": Packages as a modular solution Packages attempt to add a level of abstraction to the Java programming landscape. They provide facilities for unique coding ...


10

That is a good convention. Sometimes you want to write unit tests for package-private classes and methods also. You won't be able to call them from a unit test class placed in another package. There shouldn't be any confusion about having unit test classes in the same namespace as they shouldn't be in the class path when compiling or running the production ...


10

Although I think your current approach is probably the simplest and most straightforward, here are a couple alternative ideas: Extract your constants (and perhaps models) to a different package that is cross-compiled to all your languages. You might be able to cross-compile the entire library, but that may come with a substantial amount of problems. Just ...


Only top voted, non community-wiki answers of a minimum length are eligible