w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Python module import : what about modules imported in the imported module
Your experiment can be conducted very easily from the shell: ╭─phillip@phillip-laptop ~ ‹ruby-1.9.3@global› ‹pandas› ╰─$ echo "import module1" > test.py ╭─phillip@phillip-laptop ~ ‹ruby-1.9.3@global› ‹pandas› ╰─$ touch module1.py ╭─phillip@phillip-laptop ~ ‹ruby-1.9.3@global› ‹pandas› ╰─$ py Python 2.7.5 (default, May 17 2013, 07:55:04) [GCC 4.8.0 20130502 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import test >>> test.module1 <module 'module1' from 'module1.py'> >>> from test import * >>> module1 <module 'module1' from 'module1.py'>

Categories : Python

Import python module over the internet/multiple protocols or dynamically create module
In principle, yes, but all of the tools built-in which kinda support this go through the filesystem. To do this, you're going to have to load the source from wherever, compile it with compile, and exec it with the __dict__ of a new module. See below. I have left the actually grabbing text from the internet, and parsing uris etc as an exercise for the reader (for beginners: I suggest using requests) In pep 302 terms, this would be the implementation behind a loader.load_module function (the parameters are different). See that document for details on how to integrate this with the import statement. import imp modulesource = 'a=1;b=2' #load from internet or wherever def makemodule(modulesource,sourcestr='http://some/url/or/whatever',modname=None): #if loading from the internet, you'd

Categories : Python

Why does it take longer to import a function from a module than the entire module itself?
The entire module still has to be imported to get the name you want from it...You'll also find that the OS is caching the module so subsequent access to the .pyc file will be quicker.

Categories : Python

python c api not able to import any module into the newly created module
Resolved this in a different way : The problem is that the __dict__ attribute of a module is read-only. I am using the python/c api for 2.7.5. After using PyModule_New there was no provisioning to execute any code into the __dict__ for imports in the api. So I used a different approach. I created a module using python code rather than the python/c api. Which has the provision to to execute some code into a modules dictionary exec 'import sys' in mymod.__dict__. The sys import provides the newly created module to have access to sys.modules which has all the available modules. So when I do another import, the program knows where to look up the path for the import. Here is the code. PyRun_SimpleString("import types,sys"); //create the new module in python PyRun_SimpleString("mymod = t

Categories : Python

Explicitly accessing module var from module function in revealing module pattern
I want the function sayOhai to say "ohai" using the defined var. Assumed i do not want to change the parameter name of sayOhai, how can i access foo's value within sayOhai? You simply can't. The var foo is shadowed by the inner function parameter with the same name.

Categories : Javascript

If a nodejs module exports an object to two other modules, do changes made to that object in one downstream module propagate to the other?
here is the way I do it: var datastore = {}; module.exports = datastore; var redis = require('redis'); var client = ''; var testResults = ''; datastore.CreateDataStore = function(storePort, storeUrl, passwd) { client = redis.createClient(storePort,storeUrl); redisClient.auth(passwd, function() { console.log("redisAuth Connected!"); }); testResults = createSiteUpdater(""); } datastore.setdata = function(data, callback){ client.set(data.key, data.value, callback); } the second function is accessor functions to my database. Not sure that this is the best way, but lets me swap out different databases easily if I need to and should save any changes to the datastore object. Instead of requiring it more than one module, pass the single object around Here is a

Categories : Javascript

Python : how to import module in other module
Take a minute to look at what you're trying to achieve: you want to import the module abc.py which is a part of the package lib, so in order to import it correctly you need to specify in which package it is: from lib import abc or import lib.abc as my_import On a side note, have a look at the Python Tutorial chapter on modules. Given what @Noelkd commented, I forgot to tell you about PYTHONPATH which is an environment variable that contains the folder where Python will look for the module (like the Java CLASSPATH). You need to put your root folder inside the PYTHONPATH to avoid doing some fiddling with sys.path.append. In Bash: export PYTHONPATH=<abs. path to outdir> For example, I've put outdir in my Desktop: export PYTHONPATH=~/Desktop/outdir And the import works lik

Categories : Python

Can I add a method to a requirejs module used as dependency in another module and have it available every time the module is loaded as dependency?
Short answer: Yes. The module needs to be an object/instance (not a class) and it will work with requirejs. Long answer: When you require a module as a dependence for the first time Requirejs generates an object, and for the next times you requires the module Requirejs will return the object it generated the first time. So all the times you require a module you get always the same reference of the object. With define([], function () { var app = { //my methods. }; return app; }); and define(['app'], function (app) { app.newMethod = function (){ // ... }; }); you can use app like this: define(['app'], function (app) { app.newMethod(); }); But injecting methods from one object to an other is a really bad practice. If you need something f

Categories : Javascript

While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Does drupal "views infinite scroll" module work with "image matrix" module?
According to this issue for imagematrix module: "Views Infinite Scroll does not handle non-standard view styles". But That means that by default the 2 modules does not work together.

Categories : Drupal

Eclipse not loading dependent module in a multi module maven project
This is an ongoing problem with the m2e-wtp plugin in Eclipse: https://bugs.eclipse.org/bugs/show_bug.cgi?id=398138 I have not figured out the specific conditions on when it comes up, nor do I have a specific workaround. I recommend changing the dependency structure, if you can. Make ModuleApi dependent on ModuleImpl, for example (even if they're not), or CoreApi dependent on ModuleImpl.

Categories : Eclipse

How to automatically close a DXL scripted Dialog Box (opened from the module) when that Module is closed
It sounds like what you are trying to do is force the user to complete their interaction with the dialog box before they continue on. The only way to guarantee that the previous dialog box gets closed before the script runs again is to block all other windows until the script is complete. You can do this by using block(DB modalBox) instead of show(DB box). show allows the user to continue to interact with DOORS while the dialog is open, where block prevents all interaction with other windows until the dialog is released using release(DB modalBox). If you need the user to be able to interact with the Module or Database window while the dialog box is open, you will not be able to use this method. I hope this helps.

Categories : Misc

Change default source directory for perl module Module::Build
use Module::Build; use File::Copy 'cp'; my $class = Module::Build->subclass(code => <<''); sub process_EXTRALIB_files { my ($self, $target) = @_; while (my ($from, $to) = each %{ $self->{properties}{"${target}_files"} }) { cp $from, $to; $self->_add_to_manifest('MANIFEST', $to); } } my $self = Module::Build->new( ⋮ RESOURCES_files => {'RESOURCES/prepare/form.html' => 'RESOURCES/new/prepare/form.html'}, EXTRALIB_files => {'../../LIBS/perl/Private/DB.pm' => '../lib/Private/DB.pm'}, ); $self->add_build_element('RESOURCES'); $self->add_build_element('EXTRALIB'); $self->create_build_script; perl Build.PL ./Build ./Build manifest ./Build dist

Categories : Perl

WebDAV and WebAPI together cause Error: Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
You might have a typo issue in the declaration of handlers. Thomas Marquardt's Blog says 5.0 Troubleshooting If you receive an error similar to the one below, your section is probably invalid. HTTP Error 500.21 - Internal Server Error Handler "" has a bad module "ManagedPipelineHandler" in its module list You probably have a handler mapping that does not have the correct precondition. IIS is not forgiving in regard to typos, and preconditions are case-sensitive. The text must be preCondition=”integratedMode” or preCondition=”classicMode”. Also, another suggestion from the comments on that article: Andrew Johnson 25 Jan 2011 3:20 AM #: I found that I can also get the "Handler has a bad module ManagedPipelineHandler in its module list" if t

Categories : Asp Net Web Api

'resolver must resolve module reference to a valid module' message in Visual Studio 2012
This should help, it fixed my problem. In the project file I had several other services too which were producing the same error when trying to configure the services. By trial and error I updated one of the service references which must of been corrupt, as I am now able configure my other services. ref: http://forums.asp.net/t/1836029.aspx/1

Categories : Visual Studio 2012

Drupal module node type creation .install vs .module
you can create node_types using both node_type_save() and hook_node_info(). Drupal Core book module creates it in hook_install. But its more common practice to do so in hook_node_info() or hook_entity_info() ( node module uses hook_entity_info() ). if you implement using hook_node_info() you are more complaint with the way drupal works. For example node_type_rebuild() will only work with values defined in hook_node_info() and not node_type_save(). Imo you should be using hook_node_info() or hook_entity_info() and let drupal core handle the rest.

Categories : Drupal

Is there a way to check if a module is being loaded by multiprocessing standard module in Windows?
Yes, you can obtain information about the current process from the instance returned by multiprocessing.current_process(). In particular the Process constructor has a name argument that can be used to distinguish between child processes. Note that in python2, if you do not specify name explicitly then the module doesn't give any guarantee on the format used, hence you cannot reliably distinguish between subprocesses and the main process: you must always explicitly specify it. In python3 child processes are guaranteed to have a name with the format of Process-N with N a positive integer. Note that there is no guarantee on the name of the parent process, hence doing: process.name == 'MainProcess' Is not reliable. You should do: import re re.match(r'Process-d+', process.name)

Categories : Python

why is python argparse giving the help for imported module rather than current module?
Your tone module defines an argument parser at the module level and prints the help message as it parses your command line arguments If you only want the parsing to take place if tone is being run as a script, move the parser.parse_args() call to your __main__ test block: if __name__ == '__main__': # run as a script, not imported as a module args = parser.parse_args()

Categories : Python

Can a CDI injected EntityManager from an EJB module be passed around after wiring into JSF CDI bean in web module?
For the purpose of resource and / or EJB injection, working with JSF beans or CDI beans is equivalent. I would avoid retrieving the EntityManager in two different ways (i.e. through PersistenceContext injection and through EntityManagerFactory) inside the same application. In particular the EntityManagerFactory instantiation is a heavyweight operation. If you make MyLazyDataModel an anonymous inner class, it's much easier because you can use the injected DAO service directly, don't need to handle the EntityManager directly in the bean. You can see a concrete example in this answer. Unrelated to the concrete problem, the best suited bean scope for a lazy datatable seems to be at least ViewScoped (that is only available for jsf beans).

Categories : Java

Why does importing a TypeScript module disallow existing module extension?
I think there is a bug in typescript compiler. Please try the following, Removed the reference "reference path="foo.d.ts" and add import f = module("foo.d"); module foo { class baz extends f.foo.bar { } } I am not sure how will be the output .js. But by doing this it is not giving error in visual studio.

Categories : Typescript

How can I properly use another a module's class in another module in a multi-mod Maven SVN project?
My question is, what's exactly happening when I import Module A's class into Module B? Is Maven pulling the class from the SVN that I commited to? If I wanted to edit Module A's class so that it will perform another function in Module B, will I have to re-commit all over again, and re-install? Maven and SVN are two different things and have nothing to do with each other by default. This is what happens when you call "mvn install" on your parent project: Maven will recognize that Module B depends on Module A and therefore will build Module A first After compiling Module A, Maven will install the created moduleA.jar in your local Maven repository (usually in C:Users/.m2) Maven will then compile Module B. It will need the moduleA.jar for this and access it from your local Maven

Categories : Java

How to access method defined in a module inside another module in Ruby?
You've define the method as an instance method. If you want to use the method without an instance, it should be a class method on the module: module A module B def self.whoa puts 'Whoa!' end end end 1.9.3p327 :009 > A::B.whoa Whoa! => nil

Categories : Ruby

Loading Module B on clicking command button from another Module A in Prism 4.0 using WPF and MEF
If you provide what you've tried so far, we can help in code or teaching specific ideas. To get you started on some code, please review Developer's Guide to Microsoft Prism: Navigation and also Prism v4 Region Navigation Pipeline to get you started. You can also find many examples already out there for the concept you're trying to accomplish here on StackOverflow, at Codeplex and at MSDN.

Categories : Wpf

Joomla Module: How to read ini language strings from XML module file?
Try this, In your xml file <languages> <language tag="en-US">languages/en-US.mod_modulo.ini</language> <language tag="es-ES">languages/es-ES.mod_modulo.ini</language> </languages> in your mod_modulo.ini file EXTNAME="Mi modulo" EXTDESCR="Descripcion de mi modulo va aqui" in your default.php file have. echo "Name :".JText::_('EXTNAME'); echo "Description:".JText::_('EXTDESCR'); Hope its help you..

Categories : Joomla

typescript and breeze module cannot be aliased by a non module type
This: import breeze = module(Breeze); should be import breeze = module('path_to_breeze_module'); where the path to the breeze module is relative to the root of your app. This will only work if breeze is packaged as an AMD module which is, I think, unusual: otherwise you can just remove the import line altogether and simply include breeze in a <script/> anywhere before you load your first AMD module (presumably with require.js or similar).

Categories : Typescript

rspec for helper class expects module even though there is no module
rails follows the paradigm of convention over configuration. one of those conventions is, that you put modules into the helpers folder, because they get included into your controllers and views. that's why rspec fails when it tries to include your module, which is actually a class. if you need to have a real class in there, i think you should put it in a different directory to make it obvious, that this is not a usual rails helper! for example, if you are implementing some kind of decorator for your views, put it in a decorators folder. if you are implementing some kind of adapter for your model, put it in the models folder or some model subfolder.

Categories : Ruby On Rails

Choosing module installation, javascript or native module
OK, that's not exactly what you are looking for, but here goes… You are trying to find an NPM equivalent to Gentoo Use Flags, which doesn't exist. The closest thing you could do it publish your pure-JS version and have users directly link to the git repo instead if they want to use the native version. In package.json: "dependencies": { "mymodule": "1.2.3" // js version } "dependencies": { "mymodule": "http://github.com/mymodule-native" // native version } You users won't have to change their require to switch between versions, only a single line in package.json. Another solution would be to attempt to build the native version without raising an error if it fails. Then you can have a simple setting in your module to switch between implementations. You can have a look at this o

Categories : Node Js

GWT multi-module app not compiling when dependent module is changed
I wouldn't be surprised if incremental builds are broken in the gwt-maven-plugin, just like in almost every Maven plugin out there: https://cwiki.apache.org/confluence/display/MAVEN/Incremental+Builds There's a note about it in the sources: https://github.com/gwt-maven-plugin/gwt-maven-plugin/blob/d6464421d9ceb815db2d594ae0bf2d9ca07a1643/src/main/java/org/codehaus/mojo/gwt/shell/CompileMojo.java#L390 I tend to agree that, the maven-compiler-plugin being broken in a similar way, you should do a clean anyway in this situation. Alternatively, if you know the change is compatible with your code and shouldn't change the output of the maven-compiler-plugin, then force the GWT compilation by passing -Dgwt.compiler.force on the command line.

Categories : Gwt

Best way to access a parent Module from a Sub Module with Marionette
Unfortunately, while Marionette gives you the ability to drill down the app/module/submodule chain via the submodules property, it doesn't offer easy access to identify a Module's parent. We've encountered a few times where this could have been helpful, but never ran into a situation where not having it became an issue. That said, if you think it'll make your codebase cleaner you might try wrapping the _addModuleDefinition function to create a parent property: var func = Marionette.Module._addModuleDefinition; Marionette.Module._addModuleDefinition = function(parentModule, module) { module.parent = parentModule; func.apply(this, arguments); }; This would give you the ability to do something like App.module("Parent.Child", function(self, App, ...) { self.parent.trigger('what

Categories : Javascript

How to define module methods like those in module Math?
There're a few ways to get singleton methods, so I'm going to go over those first. We'll get to the part that lets the include Math work in a minute. So, first, if you're in a module or class body, you can define a singleton method as a method of self, like so: module Foo # Define bar as a method on self (the Foo module), thereby making # it a singleton method. def self.bar "baz" end end Alternatively, you can define them as methods on a module or class's singleton class: module Foo # Opens the singleton class of self (the Foo module). This makes # bar a singleton method (see Module#define_singleton_method for # some more on that). class <<self def bar "baz" end end end include Math, Having Your Methods, and Eating Them Too Thirdly, if you w

Categories : Ruby

perl get the path of a module inside the module?
AFAIK FindBin will show mymain.pl (and it might have been used in other modules, then the first invocation will win). Try __FILE__: my $path = __FILE__; $path =~ s/pm$/config/;

Categories : Perl

python module imports itself instead of dist module
Use: from __future__ import absolute_import in your libx.something.mimetypes module, or give it a different name. See PEP 328 - Imports: Multi-Line and Absolute/Relative for the nitty gritty details. In Python 2, imports are first resolved relative to the current module, before searching the modules path; with the above statement imports are always absolute unless you use the new relative import syntax (from . import mimetypes, etc.). The statement switches import behaviour per module; adding it to your libx.something.mimetypes module will not alter behaviour of importing in other modules.

Categories : Python

Relation between main module and related module
Related module list is managed in vtiger_relatedlists table. And add function get_attachments from CRMEntity.php for related module to your module.php file to which you have to set relation. (this is just for your information if you don't know). Any question please let me know.

Categories : Misc

How do I determine if a required module came from a gem, or was a core module?
Once require has found an loaded a library file it adds the full path to that file to the $LOADED_FEATURES array. So you could look in that array to see where it found blah $LOADED_FEATURES.find_all { |path| puts path if /blah/ =~ path }

Categories : Ruby

Magento overwrite block from module in other module
You could do something like this...to get rid of the original block and add the new one with another name, since its obviously a self rendering content block. <affiliateplus_account_register> <reference name="content"> <action method="unsetChild"><name>affiliateplus_register</name></action> </reference> </affiliateplus_account_register> But as you are just using another template i would advise you instead of your xml to simply change the template and keep everything else like it was <affiliateplus_account_register> <reference name="affiliateplus_register"> <action method="setTemplate"> <template>partner/account/register.phtml</template> </action> </reference> &

Categories : PHP

injecting module when you have access only to a module variable
It depends on when is your code actually run. I tried this plunker and it worked. app.js var app = angular.module('plunker', []); myModule.js var myModule = angular.module('myModule', []); myModule.service('MyService', function() { return {test: 'MyService'}; }); app.requires.push('myModule'); app.controller('MainCtrl', ['$scope','MyService', function($scope, MyService) { $scope.name = MyService.test; }]); index.html <head> <script src="app.js"></script> <script src="myModule.js"></script> </head> You need to add your extra modules after the app.js is loaded but within the same javascript execution sequence. Timeouts and async loading failed for me.

Categories : Angularjs

NodeJS required module not available in other modules
Each file has to include references to modules index.js var fs = require("fs"), other = require("./otherfile"); // you can now use `fs` otherfile.js var fs = require("fs"); // you can now use `fs` here One of the best parts about this is you're not locked into naming the variable a certain way in any given file. Every file is pretty much isolated from all the other files in your lib, and that's a very good thing. Also know that you can include just parts a module if you'd like var read = require("fs").readFile; read("myfile.txt", function(err, data) { if (error) { return throw error; } console.log(data); }; Explanation: Node.js does not encourage the use of globals; and as such, you should not try to implement things that depend on global variables. Whe

Categories : Node Js

Ruby modules and Module#append_features explanation
Basically, the append_features is - or should be considered - a deeply internal ruby method. The Module.include method is defined (in the "eval.c" file with the name of rb_mod_include) as a loop, which just calls mod.append_features (and then mod.included) for every Module argument passed to it. The default append_features implementation (rb_mod_append_features in "eval.c" file), calls the rb_include_module, and this is the method which does the real job. (Actually the really real job is done by the include_modules_at few lines below) It means that you are perfectly right saying that you can prevent or break this basic ruby functionality by overriding the append_features (at least if you don't call the super). The ActiveSupport::Concern actually calls the super, just in some cases it

Categories : Ruby

How to inject modules to main Angular app module on the fly
No, this is not officially supported at the moment. All the modules must be loaded in a browser (and declared as a dependency of a main application module) before AngularJS application is bootstrapped.

Categories : Angularjs

can not have require multiple modules with module.exports in it
It looks like you're attempting to pass require() an undefined variable two times. require() needs to take a string as an argument to determine what module you want to load. If the other two modules are in the same directory as app.js, try m1 = require('./module1') m2 = require('./module2') EDIT: What you're forgetting to do is m1 = new require('./module1')() m2 = new require('./module2')() Assuming that you modules look like: module.exports = function() { this.method = function(){} } Personally, instead of a function I would just return an object literal from my module: module.exports = { method1: function(){}, method2: function(){} } Then I could invoke the methods from the module's export like such: m1 = require('./module1'); m1.method1();

Categories : Node Js



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.