module

How can I initialize a module's instance variables in Ruby?

I have some modules where I would like to use instance variables in. I'm currently initializing them like this : module MyModule def self.method_a(param) @var ||= 0 # other logic goes here end end I also could call a init method to initialize them : def init @var = 0 end but this would mean I have to remember to alw...

How can I import only a couple of functions from a Ruby module?

Suppose I have a module with the methods : function1,function2,function3. I want to import function1 and function2 but not function3. Is there a way to do this in ruby? ...

Building a highly modular business application with WPF?

I'm fleshing out a WPF business application in my head and one thing that sparked my interest was how I should handle making it incredibly modular. For example, my main application would simply contain the basics to start the interface, load the modules, connect to the server, etc. These modules, in the form of class libraries, would con...

Can you define aliases for imported modules in Python?

In Python, is it possible to define an alias for an imported module? For instance: import a_ridiculously_long_module_name ...so that is has an alias of 'short_name'. ...

Checking python module version at runtime

Many 3rd party python modules have an attribute which holds the version info 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 need to check that the correct version of these modules are being used at runtime. Is there a way ...

How can i code a program that works with a front end and some modules?

It will be a desktop application, coded in visual basic (vb.net) or c#. The idea is to have just one main .exe as front end form. It will load all modules installed and display each in a different tab. This form should have functions to install a new module, update an installed module or delete. As an example, think about a tabbed pane...

ASP.NET intranet application with "plug-in" ability

Hi there! I'm working on an ASP.NET 3.5 site that is intended to be an intranet application. How would it be possible to create a kind of "plug-in" architecture, such that I can add additional functionality to the site without recompiling the site? I'm thinking of additional functionality as developing separate modules that can be comp...

Python: Importing modules from parent folder

I am running Python 2.5. This is my folder tree: ptdraft/ nib.py simulations/ life/ life.py (I also have __init__.py in each folder, omitted here for readability) How do I import the nib module from inside the life module? I am hoping it is possible to do without tinkering with sys.path. (Note: The main module being r...

circular dependency control in OCAML

Hi everyone, [EDIT] Thank you for your answer, my problem is the following : Module A called Map.ml let lst = ref [Instance1_ModuleB; Instance2_ModuleB; ...];; let is_coliding p = DoSomeWork_And_Return_A_Bool ;; .... other things here. Module B called Player.ml Open Map class player_object (x_in, y_in, name_in)= object (self) me...

How can my Perl script find its module in the same directory?

I recently wrote a new Perl script to kill processes based on either process name / user name and extended it using Classes so that I could reuse the process code in other programs. My current layout is - /home/mutew/src/prod/pskill <-- Perl script /home/mutew/src/prod/Process.pm <-- Package to handle process descriptions I ad...

programatically add module to xls 2003 using vbscript

The first part is now working [ I have the following which just seems to hang; the part that adds/deletes the module works when running in VBA I note that I'm prompted with a dialog saying 'this workbook contains links to other data sources' which I ok to, then it hangs So I tried setting the second argument to 0 and also tried 2 but sti...

How to generate a modular directory structure with Zend_Tool?

The only examples I've seen of generating a Zend Framework project with Zend_Tool create this directory structure: /application/controllers /application/models /application/views Does Zend_Tool have the ability to generate a modular directory structure (where each module has its own models, views, and controllers)? example: /applic...

Unable to get a list of installed Python modules

I would like to get a list of Python modules, which are in my Python installation (UNIX server). How can you get a list of Python modules installed in your computer? ...

Does a Perl module know where it is installed?

Hi Perl programmers, I have started creating a Perl package that contains a default email template. The MANIFEST looks something like: SendMyEmail.pm SendMyEmail/defualt_email.tt Currently I know where the module (and the template) are - but does the module itself know where on disk it is? So could the module find the default temp...

How do I spell out an integer in Ruby?

Does anyone know of a Ruby module that will take an integer and spell it out ( 1 => "one", 2 => "two", etc..)? ...

process descriptor in kernel modules

Is it possible to get a pointer to process descriptor of a process in a kernel module?If it is possible pls post how? I need to find all files opened by a process and their offset values of each file descriptor.... ...

mod_wsgi force reload modules

Is there a way to have mod_wsgi reload all modules (maybe in a particular directory) on each load? While working on the code, it's very annoying to restart apache every time something is changed. The only option I've found so far is to put modname = reload(modname) below every import.. but that's also really annoying since it means I'm ...

Test for Python module dependencies being installed

How could one test whether a set of modules is installed, given the names of the modules. E.g. modules = set(["sys", "os", "jinja"]) for module in modules: # if test(module exists): # do something While it's possible to write out the tests as: try: import sys except ImportError: print "No sys!" This is a bit cumbersome f...

Dynamic Loading of Python Modules

I'm trying to dynamically load modules I've created. Right now this works properly: import structures.index But if I try the same thing by importing it dynamically, it fails. struct = __import__("structures.index") Error supplied is: Error ('No module named structures.index',) Any ideas why? Edit: When using full scope (it s...

How do I structure Python code into modules/packages?

Assume I have this barebones structure: project/ main.py providers/ __init.py__ acme1.py acme2.py acme3.py acme4.py acme5.py acme6.py Assume that main.py contains (partial): if complexcondition(): print providers.acme5.get() Where __init__.py is empty and acme*.py contain (partial): def get(): v...