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
80
votes
4 answers

How to fix: fatal error: openssl/opensslv.h: No such file or directory in RedHat 7

I have RedHat Enterprise Linux Server 7, and I downloaded the linux kernel version 4.12.10 which I am trying to compile but when I execute the following command: make modules I get the following error: scripts/sign-file.c:25:30: fatal error:…
rainman
  • 2,551
  • 6
  • 29
  • 43
79
votes
5 answers

Use a library locally instead of installing it

I've written a script in python that occasionally sends tweets to Twitter It only uses one library called tweepy. After installing the library it works. Problem: I would like to host the script on a server where I do not have privileges to install…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
79
votes
4 answers

What is __path__ useful for?

I had never noticed the __path__ attribute that gets defined on some of my packages before today. According to the documentation: Packages support one more special attribute, __path__. This is initialized to be a list containing the name of…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
78
votes
5 answers

How do I create an importable module in Swift?

I have read through Apple's documentation for Swift and can find nothing about how to create modules or how to define class or stucture members as private or public. There are references to the import statement in the syntax but I can find no…
sprinter
  • 27,148
  • 6
  • 47
  • 78
78
votes
5 answers

How do I get the redirected url from the nodejs request module?

I'm trying to follow through on a url that redirects me to another page using the nodejs request module. Combing through the docs I could not find anything that allows me to retrieve the url after the redirect. My code is as follows: var request =…
hitautodestruct
  • 20,081
  • 13
  • 69
  • 93
78
votes
7 answers

Callable modules

Why doesn't Python allow modules to have a __call__ method? (Beyond the obvious that it wouldn't be easy to import directly.) Specifically, why doesn't using a(b) syntax find the __call__ attribute like it does for functions, classes, and objects?…
Roger Pate
76
votes
1 answer

Call a Subroutine from a different Module in VBA

Is it possible to call a function from one Module to another? I have the following code: Sub MAIN() Call IDLE End Sub MAIN is located in Module1 IDLE is located in Module2 and defined as: Sub IDLE()
Nimrod
  • 2,343
  • 3
  • 17
  • 7
75
votes
5 answers

Python: logging module - globally

I was wondering how to implement a global logger that could be used everywhere with your own settings: I currently have a custom logger class: class customLogger(logging.Logger): ... The class is in a separate file with some formatters and other…
cwoebker
  • 3,158
  • 5
  • 27
  • 43
75
votes
6 answers

How can I install a specific version of a set of Perl modules?

I'm tasked with replicating a production environment to create many test/sit environments. One of the things I need to do is build up Perl, with all the modules which have been installed (including internal and external modules) over the years. I…
Matthew Watson
  • 14,083
  • 9
  • 62
  • 82
74
votes
5 answers

How do I retrieve the available commands from a module?

To know which PowerShell modules are available on a machine I use the command Get-Module -ListAvailable This returns a list with module-type, -name and the exported commands. But the exported commands are always empty and just displaying {}. Why is…
Tom
  • 1,611
  • 1
  • 13
  • 16
73
votes
11 answers

How can I access the current executing module or class name in Python?

I would like to be able to dynamically retrieve the current executing module or class name from within an imported module. Here is some code: foo.py: def f(): print __name__ bar.py: from foo import f def b(): f() This obviously does not work…
Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
73
votes
5 answers

Web Workers - How To Import Modules

I am using ES2015 Import / Export modules. In my worker file, when I try to import functions like I normally do: worker.js import { a, b, c } from "./abc.js"; I get the error: SyntaxError: import declarations may only appear at top level of a…
Kayote
  • 14,579
  • 25
  • 85
  • 144
72
votes
5 answers

Scope of Constants in Ruby Modules

I'm having a little problem with constant scope in mixin modules. Let's say I have something like this module Auth USER_KEY = "user" unless defined? USER_KEY def authorize user_id = session[USER_KEY] def end The USER_KEY constant…
user204078
  • 1,075
  • 1
  • 7
  • 12
71
votes
13 answers

AttributeError: module 'datetime' has no attribute 'now'

I am learning Python on my own. Now I have encountered some problems. Below is my code which copy from the video who running well. import datetime print(type(datetime)) d1 = datetime.datetime.now() print(d1) when I running the code using Pycharm &…
Yq Lee
  • 821
  • 1
  • 6
  • 4
71
votes
6 answers

from ... import OR import ... as for modules

Should I use from foo import bar OR import foo.bar as bar when importing a module and and there is no need/wish for changing the name (bar)? Are there any differences? Does it matter?
embert
  • 7,336
  • 10
  • 49
  • 78