FAQ Database Discussion Community


Python: Is it better to explicitly pass instance variables to instance methods?

python,class,instance
class A(): def __init__(self): self.x = 3 @staticmethod def f(x): return x ** 2 def g(self): return self.x ** 2 def run(self): self.f(self.x) def run2(self): self.g() Which one is more preferable, run() or run2? The former pass explicitly the instance variable self.x to the function f; the latter does not....

Can a method return a new object?

javascript,class,instance
Is the following: function AnObject () {} AnObject.alloc = function () { return new this } var obj1 = AnObject.alloc(); Equivalent to: var object1 = new AnObject(); Same as: var obj1 = new AnObject().init(); var obj2 = AnObject.alloc().init(); ...

How to accumulate a value in java?

java,class,constructor,instance,accumulator
Right now, I'm learning all about class, constructors and instances. I've made a small bit of code in java and I'm stuck with this particular code. ***MY CODE OUTPUT IS SUPPOSE TO BE LIKE THIS: OUTPUT Enter amount:500 Do you want to enter amount again?(y/n):y Enter amount:45 Do you want...

Elastic Beanstalk maintain the changes made directly via ssh for new instances?

amazon-web-services,amazon,instance,elastic-beanstalk
When the app autoscale, the previous modifications made in first instance will be kept in new instances?

method on deleted instance of class still work?

c++,class,object,memory,instance
I have this code on Visual C++ 2010 #include <iostream> #include <string> using namespace std; class Human { private: int magic; int health; string name; public: int GetMagic() const; int GetHealth() const; Human(int, string); ~Human(); }; //helper int Human::GetHealth() const { cout <<"This returns Human::health" << endl; return Human::health; }...

Get value from different class inside an event

java,swing,instance,instance-variables
I have two classes: public jComboBox() { ... // this is a autocomplete jComboBox btw ... combo.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent ie) { if(ie.getStateChange() == 1) { String selectedItem = (String)getSelectedItem(); randomMethod(selectedItem); } } }); } private void randomMethod(String selectedItem){ someClass sc = new someClass(); String randomString = selectedItem; sc.getRandomString(randomString);...

JavaScript - How to set new instance as parameter, created dynamically? [duplicate]

javascript,string,oop,object,instance
This question already has an answer here: Dynamically access object property using variable 4 answers I have a method which sets a new instance to an array, created dynamically. How can I do that without the use of eval()? var Form = (function(){ function Form(params){ this.shapesArray = []; this.shape;...

Extend a Show instance to a Tuple of any size

haskell,tuples,instance
I want to create a new type of data with Haskell and create the related Show instances. I need to create the tuple Show instance with another delimiter than ,. I implemented this code (with the {-# LANGUAGE FlexibleInstances #-} pragma): newtype Data = Data Double instance Show Data where...

why does aws EC2 instance automatically starts after manually stopping it?

amazon-web-services,amazon-ec2,instance
I have a AWS EC2 instance. To avoid more billing , iam manually selecting the instance and stopping it. However in sometime i automatically starts back thereby adding to my billing. How do i permanently stop it and start manually only when i want to

Assign static List to a non-static List

c#,list,unity3d,static,instance
I came here because I have a strange issue with Unity and C# and I can't figure how to solve this. I have two C# scripts : ScriptA is instantiated one time and has static variables. It has a static list which contains points for a path. This list changes...

Only allowing one instance of a pyqt4 application [duplicate]

python,qt,python-3.x,qt4,instance
This question already has an answer here: PyQt - how to detect and close UI if it's already running? 2 answers I have created a pyqt4 app and I want to make it so only one instance (of QApplication) is allowed to run. The program reads and writes audio...

Check if TableLayoutPanel contains instance?

c#,winforms,visual-studio,instance
I would like to check if a TableLayoutPanels already contains an instance of a UserControl but it don't works like this. mainActiveContr != userControl are both an instance of the AddEntryControl so shouldn't it be false? It's true ... Contains also seems to return true, but shouldn't it return false??...

Instance of Show for Lambda

haskell,lambda,instance,show,typeclass
So, I have already defined the lambda data type as such: data LExpr = Variable String -- variable | Apply LExpr LExpr -- function application | Lambda String LExpr -- Lambda abstraction deriving (Eq, Show) Now I want to implement an instance of Show myself. I have already the function...

I can't create an instance of a class on Codeigniter

php,codeigniter,class,instance
I'm trying to create a instance of a class but I get the following error: A PHP Error was encountered Severity: Notice Message: Undefined property: DM_TemplateLoader::$load Filename: libraries/Form_validation.php Line Number: 147 Backtrace: File: C:\xampp\htdocs\DataMigrator\ci_my_app\controllers\DM_FormValidator.php Line: 13 Function: __construct File: C:\xampp\htdocs\DataMigrator\index.php Line: 292 Function: require_once Fatal error: Call to a member...

Why is interface variable instantiation possible?

c#,variables,interface,instance
As far as I know, interfaces cannot be instantiated. If this is true, why does the below code compile and execute? It allows you to create a variable interface. Why is this possible? Interface: public interface IDynamicCode<out TCodeOut> { object DynamicClassInstance { get; set; } TCodeOut Execute(string value = "");...

How to pass the instance itself to an external map at the moment of its creation?

c++,dictionary,constructor,instance
I have a class Object and a typedef: class Object { private: long int id; public: Object(void); ~Object(void) {}; long int get_id(void); }; typedef map<long int, Object> obj_map; And then I have this class App, which has an obj_map and object_counter: class App { public: static ALLEGRO_DISPLAY *display; static ALLEGRO_EVENT_QUEUE...

101: What does baseApp = (MyApp)this.getContext() do? [duplicate]

java,android,oop,constructor,instance
This question already has an answer here: What does this block of code do? 6 answers When I do this: baseApp = (MyApp)this.getContext(); What am I actually doing? as opposed to doing: baseApp = myApp.doSomething(); I'm not concern with the methods but understanding the construction. How are those 2...

Python class instances deleting themselves [duplicate]

python,class,instance
This question already has an answer here: Python object deleting itself 10 answers Python: how to “kill” a class instance/object? 2 answers I am working on a text adventure game written in Python just for fun (to see if I could do it). I am working on the module...

how to display data from database in another form label

c#,sql,database,visual-studio,instance
I'm trying to get data from database and put it in a label in a different form(student profile) (http://s30.postimg.org/w5ruf5jkh/database_post_error.png) I have exposed the label from the student profile form: public string Label9 { get { return this.label9.Text; } set { this.label9.Text = value; } } but the problem is this:...

C# singleton instance is never null

c#,null,singleton,instance
I am attempting to implement a singleton pattern in an Azure webjob. Debugging locally the instance is never null. It is always set to the singleton object itself. I feel I'm missing something brutally obvious here. public sealed class HubErrorList { private static volatile HubErrorList instance; private static object syncRoot...

What is the Javascript equivalent of a Class variable? [duplicate]

javascript,class,instance,instance-variables,class-variables
This question already has an answer here: Using Class Variables in Javascript 2 answers Edit: Thanks @Aadit M Shah for confirming. function Apple () {} Apple.someVar = null; // Class variable Apple.prototype.someVar = null; // Instance variable ...

Use variable value to check if particular instance exists, if not - create it

c#,class,instance
I have a list of images like this: public List<Image> imageList = new List<Image>(); I also have a picture class in order to collect and manipulate data about the images in the list: public Class Pic { // properties and stuff } And then I have a function that takes...

When to use constants instead of instance variables in Ruby?

ruby,variables,instance,constants
I understand that instance variables are mean to be states, and constants are meant to be constant. Is there any reason (besides convention) to use a constant instead of an instance variable? Is there a memory/speed advantage to using constants?

Javascript this point to last object instance

javascript,object,this,instance
Before all, sorry for my bad english. I'm having problem with the context of a jquery Plugin i'm developing. Each instance I make of the plugin below, this points to last object. Example: var a = $("#a").EscribirConAdjuntos(); var b = $("#b").EscribirConAdjuntos(); var c = $("#c").EscribirConAdjuntos(); It results that a and...

cannot reference before supertype has been called java

java,constructor,instance
I have a class Ship public class Ship { private String name; private boolean loaded; private int size; private boolean bIsDefeated; private int gunpower; public Ship(int size, int gunpower, String name) { this.size = size; this.gunpower = gunpower; this.name= name; loaded = true; bIsDefeated = false; } } and Submarine...

Rails: Can I create and save an object instance within a class method on a model?

ruby-on-rails,class,model,instance
Is it possible and kosher to use a class method on a model to create a new instance of the same model? The scenario is that I want to interact with an external API, create an instance on the other service, and then once completed successfully store that new object...

Access to composer autoloaded files in laravel 5

laravel,instance,bind,autoload
Trying to use a non-Laravel package: https://packagist.org/packages/luceos/on-app Edited composer.json to require it and did the composer install, update, then dump-autoload -o. This package requires an initialization: vendor/luceos/on-app/src/OnAppInit.php Which isn't a class and only has the one method. But it doesn't seem to be loaded when I try to bind it...

Init Method in Singleton Class (Objective-C)

ios,objective-c,singleton,instance,init
I have a question regarding the safe way of implementing a singleton class in Objective-C. My background is mostly in web-development (PHP) but I know that in Obj-C things are quite different. For instance I have this custom class MyClass that I want to be singleton: static MyClass *sharedInstance =...

understanding getter methods and instance variables [closed]

variables,instance
If a class has 5 instance variables, what's the most number of getter methods that it can have? I'm not sure and need help with this topic, can someone please answer this? Thank You.

Python returns instance instead of array

python,numpy,matplotlib,plot,instance
The structure of my program is simple. I have two .py files, say file1.py and file2.py. file1 is UI, file2 is calculations. When a button is pressed, file1 sends the user input to file2 and file2 does calculations and then it is supposed to return an array to file1 so...

c# how to use a previously created instance of a class from a new class

c#,class,object,instance
im learning c# by reading tutorials and making my own programs, and I'm facing the next scenario, i will be using an example: I created a Class in a different file and made an instance of it in form1 to fill it's propierties, ie: //Person.cs file public Class Person {...

Instance method returns correct array from one view controller but null from others

objective-c,xcode,methods,null,instance
This is my first post so apologies for any errors I make, but this has been frustrating me for hours now and I cannot find a solution. I have an app that uses a UITabBarViewController that has 3 tabs: FirstViewController, SecondViewController and ThirdViewController. I have an NSObject class (Manager) where...

How to share an instance created in main with a class in another module

python,class,share,instance,global
I am having a problem with how to share a class instance between modules. Below is not the actual code, it is a simplified representation of what I'm trying to do. The variable in question is thePlot. If I make it a global, I get 'global name not defined' type...

Python access mother class fields

python,tree,iterator,instance
While writing an iterator for a tree class in python I stumbled upon the issue, that I apparently cannot access fields and methods of the mother class without instanciating an iterator instance with a reference to an already existing Tree instance, so I always need to call the iterator like...

Passing a value into a class to be used when the class is instantiated in Swift

class,swift,instance
When creating an instance of a custom class, I want to pass a value back into the class declaration, to be used when it's instantiated. I tried doing this through a property, but that doesn't work. What is the correct way to achieve this? (Apologies if I'm not wording the...

Python inst/klass instead of self?

python,class,naming-conventions,instance
Sometimes self can denote the instance of the class and sometimes the class itself. So why don't we use inst and klass instead of self? Wouldn't that make things easier? How things are now class A: @classmethod def do(self): # self refers to class .. class B: def do(self): #...

Java: Calling a method of an instanced instance

java,methods,call,instance
Beginner here. Main.java: public int foo = 0; public static void main(String[] args){ Window f = new Window(); // do some other stuff } public static void incrementFooEverySecond(){ while(true){ foo++; bar.repaint(); // <- Problem here! Thread.sleep(1000); } } Window.java: public class Window extends JFrame { public Window(){ this.setSize(X, Y) //......

Haskell: `==' is not a (visible) method of class

haskell,compiler-errors,instance,equality,typeclass
So, when I compile the following piece of code edited: instance (Eq a) => PartOrd a where [] == [] = True (x:xs) == (y:ys) = x==y && xs==ys _==_ = False xs /= ys = not (xs == ys) I get: `==' is not a (visible) method of class...

JAVA How to change instance fields values without copying new instance reference [duplicate]

java,field,instance
This question already has an answer here: How do I copy an object in Java? 19 answers Let say I have class A public class A { private int field1; private String field2; ... } I create new Instance of A, then second Instance of A: A a1 =...

Is an instance of a class automatically created when you first call a static method

java,instance,static-methods
I would like to know if you have a class with only static methods in it, does an actual instance of the class get created somewhere when you call 1st static method? This is somewhat confusing to understand in terms of memory management as you never actually call the constructor...

Is there a difference between instantiation with parentheses or without?

php,oop,instance
What's the difference between these 2 piece of codes? <?php $object1 = new User(); //^^ $object1->name = "Hello"; echo $object1->name; class User {} ?> And: <?php $object1 = new User; //^ $object1->name = "Hello"; echo $object1->name; class User {} ?> I get the same output: Hello So is there any...

Getting instance of a jQuery plugin

javascript,jquery,jquery-plugins,instance,sceditor
I'm using SCEditor and am loading it as such: $(document).ready(function() { // Create var to store emoticons var emoticons = false; $.getJSON('../../images/emoticons/default/emoticons.json') .done(function(response) { emoticons = response; }) .always(function() { // always initialize sceditor $(".sceditor").sceditor({ // Options here... }); }); }) Now, I'm wondering how I go about getting the...

Trying to create an instance of a struct with an predefined image. Unsure if struct or instance code is off

ios,swift,struct,instance
So I have created the following struct : import Foundation import UIKit struct restaurantmodel { var restitle: String var restype: String var resimage: UIImage(named: "") } and an instance of this struct let restaurant1 = restaurantmodel(restitle: "earth cafe", restype: Chicken", resimage: UIImage(named: "earth.png")) I have tried a number of different...

How Do you Reference Coldfusion Instances in Clustered Server Environment

coldfusion,instance
If there are multiple Coldfusion instances on a server, in a clustered server environment, how do you reference it? For instance, if we had multiple servers and we wanted to find out which server we were hitting with a web call we could use #CGI.Server_Name# which would gives the IP...

List item in another class disappears when removing as passed instance

c#,list,oop,instance
I'm currently freakin out a little. I'm passing a List to a method of another class and in that class I'm using a different variable name (encapsulated). But here it is: When I remove an item from the list within the method the item disappears in the other variable as...

Instantiate once

c#,animation,unity3d,instance
I know that it is a commonly asked question but, I swear I did what I had to do so I am turning to you guys to tell me what is wrong with my work that. I have to spawn an "indicator above an object after it gets thrown by...

How can I assign a new action to an existing method?

c#,.net,class,methods,instance
I've created a class in C# which uses the method "Action". public void Action() { } The method is empty because, when a new instance of the class is created, the user should be able to define what the method does. One user may need the method to write to...

Closure axiom for instances so that reasoner can correctly classify instances in ontology

instance,classification,owl,ontology,reasoning
I am a geographer and a new comer in the field of ontology trying to make sense out of these two. Therefore, I have created a simple ontology, as follows: Thing Feature Lane Segment(equivalent to Arc) Geometry Arc (equivalent to Segment) Node Dangling_Node Intersection_node you can find the .owl file...

move redmine database to another instance

database,instance,move,redmine,migrate
I have redmine 2.5.3 installed on a virtual machine ( See Martin Denizet blog for HowTo install it ) Now, I want to move previous redmine DB (version 1.3) to this virtual machine. Both of redmine versions are in working , but virtual machine is not in production environment yet....

unwanted object property changed when changing another object property c#

c#,object,properties,copy,instance
from what i understand in other posts i know that my objects use same place in memory but how to separate these objects? i tried to use new but it didn't work or i didn't used it correctly. Note that i didnt paste setter and getter here. class Supermarket {...

How to set up a single object instance for an application?

c#,wpf,mvvm,instance
I'm following an MVVM pattern for my application and to prevent memory leaks, I need to cut down the number of object instances to one. This object instance should then be handed of to the other classes where needed. In my current implementation the instance is being set up in...

Call an instance of a GUI at runtime

java,user-interface,instance
I have a GUI called SupermarketCheckoutGUI in Java. It runs fine, but how would I go about calling the GUI again at runtime, so another window pops up and gives me the 'same' GUI. I'm wanting to do this through a button called: 'Add Checkout' -- What code could I...

Why doesn't this class execute properly?

java,class,instance
Here is my first class called World public class World { private static char[][] world2D; private int characterRow; private int characterColumn; public World(int width, int height){ world2D = new char[width][height]; characterColumn = 0; characterRow = 0; for(int i = 0; i < world2D.length; i++){ for(int j = 0; j <...

How did I call different class instance in a class method?

python,class,instance
I was building a pub-sub NAT breaker using zerorpc and get it done yesterday. Now I am trying to modify my code in order to run publisher as a daemon by using Sander Marechal's code sample. Here is my publisher.py #!/usr/bin/env python # -*- coding: utf-8 -*- import zerorpc import...

Can you use too many new instances in C# to cause memory issues?

c#,memory,xna,instance
I'm creating a game in C# and XNA 4.0. It consists of multiple levels with a player character, enemies, things to collect, etc. The levels are created using a Level class similar to the following. List<Level> levels = new List<Level>(20); //This is a list to hold all of the levels...

Meaning of syntax of new object creation of a child class in Java?

java,class,interface,instance,parent-child
I have below java program which i wrote while going through a java tutorial. public class Primitive_prac { public static void main(String[] args) { // TODO code application logic here Parent obj1 = new Child(); Child obj2 = new Child(); System.out.println("ojb1 is instance of Parent: " + (obj1 instanceof Parent));...

Pass PHP class instance through AJAX?

javascript,php,jquery,ajax,instance
I recently wrote a PHP wrapper class for a new API we are using and have been asked to setup a demo which makes use of it. Certain features can be called directly from PHP, however things such as performing actions on button clicks requires I make use of JS/AJAX....

Get instance of JQuery UI popup

jquery-ui,dialog,instance
I am creating a JQuery UI popup this way: function ShowJQueryStandardDialog(searchTarget, title, width, height, closeFunction) { var $dialog = $('<div id="dialogDIV"><iframe id="dialogIFrame" frameborder="no" scrolling="auto" src="' + searchTarget + '" width="' + (width - 50) + 'px" height="' + (height - 50) + 'px"></iframe></div>'); $dialog.dialog( { modal: true, title: title, show:...

What happens when we create an instance of class in same class? [duplicate]

c#,class,instance
This question already has an answer here: How does creating a instance of class inside of the class itself works? 4 answers What will actually happens with references when we create an instance of the class in that same class like this: public class Class1 { public Class1 instatnce;...

ghci unexpected behavior instance of class

haskell,instance,gchi
I've been going through Bryan O'Sullivan's and co's "Real World Haskell," and came across what I would call unexpected 'laxness' on the part of GHCi, version 7.8.3, under Windows. I ":loaded" the following - module JSONModule where data JValue = JNumber Double | JBool Bool deriving ( Show, Eq, Ord...

importing haskell module says “not in scope”

class,haskell,instance
I created a Tree structure in a file called Tree2.hs module Tree2 ( Tree ) where data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show) then I imported it and tried to use it as an instance of a class import qualified Tree2 class YesNo...

How can i access a Model in another Namespace in Zend2?

php,model,namespaces,instance
i am new to zend2, i have created a model(class) in a namespace, and i want to make an instance of this model within a controller from another namespace , so do you know how can i do this? Thanks Tarek...

Why do two programs have forward referencing errors while the third does not?

java,static,instance,forward
The following does not compile, giving an 'illegal forward reference' message: class StaticInitialisation { static { System.out.println("Test string is: " + testString); } private static String testString; public static void main(String args[]) { new StaticInitialisation(); } } However, the following does compile: class InstanceInitialisation1 { { System.out.println("Test string is: "...

How to instantiate a .NET class in PHP which has a parameterized constructor?

php,.net,oop,constructor,instance
I want to use a class of .NET in PHP and am using the DOTNET class of PHP for this purpose. I want to instantiate a class which has a parameterized constructor. $e = new DOTNET($full_assembly_string, $full_class_name); How do I pass constructor arguments through this API?...

NullPointerException (Java)

java,variables,methods,null,instance
I've tried looking at posts on this issue but am still having some trouble with this error in my code. So in the fourth line, I create an instance variable called SongDatabase to access the SongDatabase class. But when I get down to the line, SongDatabase.addNewSong(); under case 1, I...

How to make a default instance in Ruby as in Prime class?

ruby,class,module,instance,default
I would like to make a class or maybe a module which can be loaded / required with "require" or "require_relative". However, for simplicity I don't want to instantiate any objects, just start using its methods, similar to Ruby's Prime class. How can I achieve this? require "my_module" puts My_module.convert("data")...

Accessing a variable stored within a class Swift

class,swift,instance,uipickerview
I can't figure out why I can't access this variable, see below, I want the value of sport result when it's clicked, however sportResult.selectedSport returns nil? let sportPickerData = SportPickerData() override func viewDidLoad() { super.viewDidLoad() sportPickerView.delegate = sportPickerData sportPickerView.dataSource = sportPickerData class SportPickerData: NSObject, UIPickerViewDataSource, UIPickerViewDelegate { var sports =...

Cannot connect via ssh to FiLab ubuntu instance

ubuntu,ssh,instance,pem,filab
I try with ssh -i file.pem [email protected] and I get the timeout error. What I did before: Create the instance on the FiLab panel Add a floating ip Create and add a keypair for remote access Download de file.pem and give it 600 permissions Look for the missing documentation Send...

How can we make sure that we can just create one instance of a class?

java,class,design-patterns,instance
This was an interview question. The interviewer presented me a class Person and another Class Community. He wanted to know what can we do to make sure that within the Class Community, the instance of the Class Person can be called once. My approach was to define a boolean flag...

Python: asking if two objects are the same class

python,polymorphism,instance
I have a class Animal and other animals inherit from it (e.q. Sheep, Wolf).I want to check if two objects are the same class and if so, it should create new object of the same class and if they are not, they are fighting. if x and y same object:...

Linq to Entities & WPF - save only entities related to a view

c#,linq,entity-framework,save,instance
[EDITED] I am looking for a way to implement Linq To Entities in a WPF (MVVM) application and make each View (or ViewModel) responsible to manage their underlying entities separately. Here is an example of a simple structure and what I would like to achieve: [Customers] (1..1) <----> (0..* )...

How to call a singleton method from a Java POJO?

java,methods,interface,singleton,instance
I wondered if it would be possible to call from a POJO a singleton bean's method through its interface. Maybe this idea is wrong or the architecture...but this is what I would like to accomplish if it is possible, because this is the architecture of the project. I notice that...

class method “does not contain definition for and no extension method”

c#,class,methods,instance
I am trying to follow a tutorial of C#, but I'm stuck on class methods, It says that it cannot find the method even though it's there. So clearly I'm missing something but what? I think it has something to do with not finding the class 'Point' within the method...

Why does this work? (Java, Graphics object)

java,text,graphics,instance,antialiasing
Here's my code: public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g.drawString("This is my string", 200, 200); } This works correctly; the text comes out as anti-aliased. However, why does it work? The text is drawn by the g object, however as far as I can...

Ruby can an instance variable be printed instead of the instance address?

arrays,ruby,class,instance,instance-variables
I was recently experimenting in ruby and came across a snag. I want to push a class instance to an array and instead of it output this when the array elements are printed: [#< WeaponItem:0x00000002a28058 @wName="M16A1", @mP=5, @mxP=35 >] I instead want it to output: ["M16A1"] but symbols and instance...

How much string objects are created (String.format())?

java,string,instance
After a dispute with my colleague we couldn't find a solution. So my question for(int i = 0; i < 2; i++) { String.format("Variable i = %d", i); } How much variables will be created during running this code? I have an opinion, that here can be created 4 variables:...

IronPython strange method calling

list,methods,call,instance,ironpython
Why does calling a method like this in ironPython work?: from System.Collections.Generic import List class test: mem = None def __init__(self): # !No Instance created !!! self.mem = List[int] def doSomeThing(self): if self.mem.Contains((List[int](), 123): pass I can't get the behaviour of IronPython in this case: self.mem.Contains((List[int](), 123):. Does any one...

Access an instance of a component created by Ractive Load

components,instance,ractivejs,ractive-load
Inside a component, I am happily using the syntax below to load additional components, if and when needed: <!-- Import example component --> <link rel='ractive' href='internal-example.html' name='InternalExample'> My question is, how can I access this example component instance created by Ractive Load inside another component? Important: I can define where...

Instance Show for specific data

string,haskell,instance,show
I have defined the following type: data Taula = Taula String [[String]] And I created the following instance: instance Show Taula where show Taula [( n , i , c )] = show Taula [( n , i , c )]++ "\n" show ( l : ls ) = show...

How to split list of (X,Y) coordinates of path into seperate list of X and Y coordinates?

python,python-2.7,split,coordinates,instance
In the following function, 'graph' is a 2d grid list consisting of ones, zeroes and a 'two' (of obstacles, open areas and target respectively), 'start' is the point to start the search from. def bfs(graph, start): fringe = [[start]] # Special case: start == goal if start.val == 'g': return...

Android - pass data to singleInstance activity

android,android-activity,instance
I have an activity that is defined in the manifest as: android:launchMode="singleInstance" Now I want to move to that activity from a different activity that has no idea that it exists (no reference to the existing instance) and at the same time to pass in a variable. I used to...

Group instances based on NA values in r

r,file,csv,instance,na
I am reading a csv file and unfortunately my dataframe has many missing values. A small snip is as following: df <- data.frame(Size= c(800, 850, 1100, 1200, 1000), Value= c(900, NA, 1300, 1100, NA), Location= c(NA, 'midcity', 'uptown', NA, 'Lakeview'), Num1 = c(2, NA, 3, 2, NA), Num2 = c(2,3,3,1,2),...

Defining own instance classes

class,haskell,instance
I struggle with creating own instances for my datatypes. I defined a type like: data Breakfast = Egg | Sausage Int | Bread Breakfast deriving (Eq, Show) and want it to be an instance of the class Ord. I want to compare it by some rules like: A Egg is...

node creating instances via costructors

javascript,node.js,class,constructor,instance
While experimenting with nodejs I encountered a problem of enabling isntances creation via Constructors. I create simple cart basket functionality. I got file cart.js var items = []; function addItem (name, price) { items.push({ name: name, price: price }); } exports.total = function () { return items.reduce(function (a,b) { return...

While in another module. How i can access class methods from an instance when im currently in another class?

python,class,instance
Is it possible to access to class methods from an instance of a class (foo) while in another class (bar), which is in another module? I know this code is wrong and don't work. But i hope you see what i want to do. Or is there a better way...

c# - Unique instance of a subclass

c#,interface,singleton,instance,subclass
I'm asking the question here cause i'm not finding the answer... Maybe i'm not looking for the right terms... My question is pretty simple, I have an interface class in C#, the thing is that one of the requirements of the program is that one and only one instance of...

set value to generic type

c#,reflection,instance,generic-type-argument
I have this function: the variable c obtains all the properties of my class <T> in this case: c -> Id Key Value public List<T> ReadStoreProceadure<T>(string storeName) { var result = new List<T>(); var instance = (T) Activator.CreateInstance(typeof (T), new object[] {}); var c = typeof (T); var data =...

Haskell custom data type, instance Num, and redundancy

haskell,types,instance
I'm developing a small set of weightlifting utilities in Haskell as a learning exercise. I've defined a data type Weight such that: data Weight = Wt Float Unit deriving (Show, Eq) data Unit = Lb | Kg deriving (Show, Eq) instance Num Weight where Wt x Lb + Wt y...

Multiprocessing: How to write separate log files for each instance while using pool.map?

python,class,logging,multiprocessing,instance
I want to create a class where each instance writes its own log file. This works fine when I use a function instead of a class (or when I don´t use multiprocessing): import multiprocessing, logging def setup_logger(name_logfile, path_logfile): logger = logging.getLogger(name_logfile) formatter = logging.Formatter('%(asctime)s: %(message)s', datefmt='%Y/%m/%d %H:%M:%S') fileHandler = logging.FileHandler(path_logfile,...