Questions tagged [module]

A logical subdivision of a larger, more complex system.

Modules are a convenient way to break down a larger problem and divide it into smaller problems/solutions. This way the main problem can be broken down into separate parts that can be worked on independently. For example, one module could consist of a the printing functionality of program, which can be handed to one programmer. The GUI (Graphical User Interface) could be another module, handed to another programmer, and so forth.

Modular design is meant to improve efficiency and speed of development by allowing programmers to work on specific aspects of the program independently of each other.

22551 questions
148
votes
18 answers

Maven: Non-resolvable parent POM

I have my maven project setup as 1 shell projects and 4 children modules. When I try to build the shell. I get: [INFO] Scanning for projects... [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project module1:1.0_A0…
Will
  • 8,246
  • 16
  • 60
  • 92
148
votes
5 answers

Using the Underscore module with Node.js

I've been learning about node.js and modules, and can't seem to get the Underscore library to work properly... it seems that the first time I use a function from Underscore, it overwrites the _ object with the result of my function call. Anyone…
Geoff
  • 9,470
  • 13
  • 52
  • 67
148
votes
8 answers

__getattr__ on a module

How can implement the equivalent of a __getattr__ on a class, on a module? Example When calling a function that does not exist in a module's statically defined attributes, I wish to create an instance of a class in that module, and invoke the method…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
147
votes
7 answers

Checking a Python module version at runtime

Many third-party Python modules have an attribute which holds the version information for the module (usually something like module.VERSION or module.__version__), however some do not. Particular examples of such modules are libxslt and libxml2. I…
Gruff
  • 1,748
  • 2
  • 13
  • 8
146
votes
13 answers

Does Python have a package/module management system?

Does Python have a package/module management system, similar to how Ruby has rubygems where you can do gem install packagename? On Installing Python Modules, I only see references to python setup.py install, but that requires you to find the package…
tommy chheng
  • 9,108
  • 9
  • 55
  • 72
145
votes
5 answers

Import module from subfolder

I want to import subfolders as modules. Therefore every subfolder contains a __init__.py. My folder structure is like this: src\ main.py dirFoo\ __init__.py foofactory.py dirFoo1\ __init__.py foo1.py dirFoo2\ …
Razer
  • 7,843
  • 16
  • 55
  • 103
145
votes
12 answers

Python way to clone a git repository

Is there a Python way without using a subprocess to clone a git repository? I'm up for using any sort of modules you recommend.
Mike
  • 7,769
  • 13
  • 57
  • 81
144
votes
7 answers

Split a module across several files

I want to have a module with multiple structs in it, each in its own file. Using a Math module as an example: Math/ Vector.rs Matrix.rs Complex.rs I want each struct to be in the same module, which I would use from my main file, like so: use…
starscape
  • 2,739
  • 5
  • 26
  • 36
140
votes
5 answers

JavaScript module pattern with example

I can't find any accessible examples showing how two (or more) different modules are connected to work together. So, I'd like to ask whether anyone has time to write an example explaining how modules work together.
Srle
  • 10,366
  • 8
  • 34
  • 63
136
votes
7 answers

ruby inheritance vs mixins

In Ruby, since you can include multiple mixins but only extend one class, it seems like mixins would be preferred over inheritance. My question: if you're writing code which must be extended/included to be useful, why would you ever make it a class?…
Brad Cupit
  • 6,530
  • 8
  • 55
  • 60
135
votes
12 answers

Is there a standard way to list names of Python modules in a package?

Is there a straightforward way to list the names of all modules in a package, without using __all__? For example, given this package: /testpkg /testpkg/__init__.py /testpkg/modulea.py /testpkg/moduleb.py I'm wondering if there is a standard or…
DNS
  • 37,249
  • 18
  • 95
  • 132
135
votes
14 answers

ImportError: No module named six

I'm trying to build OpenERP project, done with dependencies. It's giving this error now Traceback (most recent call last): File "openerp-client.py", line 105, in File "modules\__init__.pyo", line 23, in File…
asadullah07
  • 1,461
  • 2
  • 10
  • 9
134
votes
4 answers

Go update all modules

Using this module as an example (using a specific commit so others will see what I see): git clone git://github.com/walles/moar Set-Location moar git checkout d24acdbf I would like a way to tell Go to "update everything". Assume that the…
Zombo
  • 1
  • 62
  • 391
  • 407
131
votes
2 answers

Python module with a dash, or hyphen (-) in its name

I have an existing python module with a dash in its name, foo-bar.py Changing the module name is something I would prefer to avoid as the module is shared, and I would have to chase down all the places it is used so that my special case will…
Skip Huffman
  • 5,239
  • 11
  • 41
  • 51
131
votes
5 answers

List all the modules that are part of a python package?

Is there a straightforward way to find all the modules that are part of a python package? I've found this old discussion, which is not really conclusive, but I'd love to have a definite answer before I roll out my own solution based on os.listdir().
static_rtti
  • 53,760
  • 47
  • 136
  • 192