Questions tagged [instance]
In object-oriented programming an instance is an occurrence or a copy of an object, whether currently executing or not.
5,713
questions
0
votes
0
answers
11
views
How to loop through all instances of a certain class
I create various instances (objects) of a certain class. To loop through all instances, I give to each object a specific property 'name' with the same name as the object name and then create an array ...
0
votes
0
answers
16
views
Sublime Text SFTP not connecting to ubuntu EC2 instance
I am dealing with connecting to my ubuntu EC2 instance. I am unable to connect with my instance using SFTP. My sftp-config.json file is as follows:
{
"type": "sftp",
"host&...
0
votes
0
answers
41
views
Why is my Google Cloud instance running out of free space?
I'm having the same problem with 2 different instances in Google Cloud within 1 day. The instance crashes and in the logs the message: "No space left on device. gpasswd: cannot lock /etc/group; ...
-2
votes
1
answer
56
views
GCP - I cant connect via ssh [closed]
Ok - so I am pretty new to all things cloud-based.
For context, I am trying to create an instance that can be used to access Kali Linux (already uploaded the image and such) - so that I can execute ...
0
votes
0
answers
5
views
unable to create an instance of a class in a for loop in python
class node:
parent=None
data=None
children=[]
def __init__(self, parent, data):
self.data=data
self.parent=parent
def get_children(self):
return self.children
def get_data(...
0
votes
1
answer
33
views
how to use the comparison attribute in a static method between instances of a Rectangle in python
class Rectangle:
"""created a class Rectangles, assigning values"""
number_of_instances = 0
print_symbol = "#"
def __init__(self, width=0, ...
-3
votes
0
answers
31
views
creating instances of a class with csv-file [closed]
I'm trying to create many instances of a class at once using a csv-file. I have a class called container and a csv-file with information about "Location" "Color" "Size"......
-2
votes
0
answers
57
views
How to create an instance of private nested class with parameters using Expression
Given the class below (excerpt from Xamarin.Forms Grid class):
public class Grid {
...
private class public GridStructure(Grid grid, double width, double height, bool requestSize = false) {
...
0
votes
0
answers
5
views
GCloud VM Instance and Python Scripts
I currently have a VM Instance (Linux Debian) within google cloud that has a functioning environment for my python project, and everything works when inputted: "python3 run.py" via SSH ...
0
votes
1
answer
44
views
What does 'this' do when no instantiated variable follows it? [Java] [duplicate]
I'm not entirely sure how to word the question properly in google without returning this.instanceVar, so any and all help is sincerely appreciated.
public class PracticeThis {
private String str;
...
0
votes
0
answers
18
views
Single Managed Instance with multiple environments
I want to migrate 3 on prem Sql Server environtments (DEV-QA-PROD) to Azure Sql Managed Instance. Every environment has around 10 databases which 350gbs in total. Do I need to create separate Managed ...
1
vote
0
answers
19
views
Python mock.patch class instance attribute
Is it possible to patch an instance attribute of a class with only a path string and not directly by importing the class and using mock.patch.object
Example:
file.py
class A:
def __init__(self):
...
1
vote
2
answers
31
views
Check if instance of python class has attribute without instantiating the class
Is it possible to check if an instance of a class has an attribute without (being able to) instantiating the class?
Example:
class A where I lack knowledge about arguments to instantiate:
class A:
...
0
votes
0
answers
25
views
Why does strings are not instance of String in javascript? [duplicate]
I found that regular strings have same prototype of strings instantiated of new String()
but why they are not - regular strings - instance of String
console.log("hello" instanceof String); //...
0
votes
0
answers
10
views
Fatal error: Uncaught TypeError: Return value of route() must be an instance of Pecee\Http\Url
I'm trying to get partURL from the object but I dont understand what a hell it want in real.
$out = Router::getUrl($name, $parameters, $getParams);
dump($out);
The code above returns that object
...
1
vote
1
answer
35
views
How to create a class just after starting Django server and access its members later in views.py
I encountered a simple issue in Django, there were similar questions on this forum but haven't answered correctly so i'm writing it again.
My issue is just same as this question. How to instantiate a ...
0
votes
1
answer
30
views
Python setters do not apply to instantiation?
I am trying to make a programme that allows you to perfrom various forms of chemical analysis on some user defined molecule. So far, I have defined a Molecule object with a coordinate property ...
0
votes
0
answers
25
views
GCP...Network Status keeps spinning
19 out of 48 VM instances are down...so we turned them off and then back on later. But now we can't access them via SSH. We even tried the in browser ssh ...but no use. It says VM status is OK, but ...
-2
votes
1
answer
32
views
Why can't you call a non-static method from a static method within the same class?(Cannot make a static reference to the non-static field) [duplicate]
In Java we can use
non-static variables inside non-static methods without creating an
instance within the same class.
static variables inside non-static methods without having an issue within the ...
0
votes
1
answer
49
views
Running two instances of the same Java application [closed]
I want to start two instances of the same Java project. I am able to start two instances by clicking on the "Run" button twice, but when I click "exit" for the first instance, it ...
0
votes
0
answers
20
views
How to change/swap a device instance ID using devcon in windows 10
I need to manually change a device instance ID for a driver on my system, because an used driver needs to have exactly the same device instance ID as on my other systems. Some systems install the ...
0
votes
1
answer
34
views
How can I create a new instance from inside a static method in python?
I've a small problem, I have a method in another class that scans a folder and for each file in that folder I need to create new folders according to the date of the files to organize and initiate a ...
0
votes
0
answers
73
views
Godot Specified cast is not valid when adding child to node
Trying to make a boids simulation in Godot, and I think I have the rules set up right for movement however when trying to make a C# script for the node that will hold all the instances of each boid ...
0
votes
0
answers
32
views
How to modify p5js code to work in instance mode
The following code works, but I want to be able to have multiple canvasses with different background colors and sizes etc. - how do I modify the code to turn it in to a p5 instance?- I can't get the ...
0
votes
0
answers
12
views
Javascript instance with variable method [duplicate]
Is there a way to make an instance string / method variable?
For example
function drag(type){
//replace type in string below
fabric.type.prototype.controls.moveObject = new fabric.Control({
...
0
votes
0
answers
19
views
get instance of an anonymous class in java [duplicate]
How do I get the anonymous class instance in main() ?
public interface AAA {
static void of(){
class BBB {
public static CCC instance() {
//anonymous class
...
1
vote
1
answer
30
views
How to get the active instance template name in a managed instance group
I am trying to get the instance template name of an instance group. In the GCP console, the instance template is included in the display (see sample screenshot). However, i cannot find a gcloud ...
0
votes
0
answers
16
views
Calendar Provider - Instance query only returns first one of recurrent events
I'm building an Android application to manage my calendar events in a easier way. So I want to show in a recyclerview all the instances for every event, including recurrents. But how I said in the ...
0
votes
2
answers
52
views
Java - method that returns a class instance to different class?
I'm a beginner and have tried searching but nothing is coming up, apologies. I have 2 classes, I don't know how to link the rewardCoins (oneCoin/twoCoin/threeCoin) so that if called, it adds coins to ...
-1
votes
1
answer
50
views
Counting instances of modules in SystemVerilog
I am attempting to design a simple CPU and I ma using SystemVerilog to design and ModelSim to simulate the design. I am trying to set up some code to count the number of instances of a specific module....
0
votes
0
answers
15
views
how can i print shuffled mycardset using instance? [duplicate]
I try to print cards shuffled and I already made the set of all poker cards by
class Deck(Cards):
def __init__(self):
self.mycardset = [(f'{y} of {x}') for x in self.suites for y in self....
0
votes
1
answer
28
views
Attempting to Reference a Class Object Within Another Class to Avoid a 2nd Instance of that Class
1. Explanation of error and my logic
I am having trouble figuring out why using a referenced object from one class into a separate class is not working the way I thought it would. I have included ...
0
votes
0
answers
45
views
Create new instance of a given object, using same arguments provided in __init__
Given any iterator, I want to be able to pass this iterator into my function, to return a new iter object that cycles through the given iter infinitely. E.G
class range:
def __init__(self, min, ...
0
votes
0
answers
11
views
How to edit values of a specific instance of a class with another specific instance of a class within a vector in javascript
i am currently attempting to code a little game in Javascript, it is not going well. i am currently stuck at the start, i have only just been able to work out how to get the class working properly. ...
0
votes
0
answers
23
views
How do we create a new instance of a bullet every time I press a key button is pressed, instead of shooting the same bullet over and over [duplicate]
I'm creating a pygame that involves 2 tanks shooting at each other
and a bullet. I've managed to create the bullet and get it to move,
but I'm not sure how to create a new instance of a bullet ...
0
votes
2
answers
78
views
Creating and storing objects in a container without using new?
Say I have the class
class A{
int value;
public:
A(int val) : value(val) {};
}
I store pointers of instances in a collection such as vector using for loop
std::vector<A*> myCollection;
...
0
votes
2
answers
54
views
create an instance of a model by clicking a button
I am pretty new to Ruby and I am working on a hangman game .
What I am trying to do is create a new game when the user simply click on a button and I want that "click" to redirect to the ...
0
votes
1
answer
35
views
Instance sharing across classes
I have this python script which has a listener class and a main class. A serial stream is created in the main class and a listener instance is created in the main class. The whole purpose of the ...
0
votes
0
answers
15
views
why does add_action or add_shortcode not create an instance of a class
I wanted to create an instance of a class when my program start add_shortcode(), but I find it not worked.
Does anyone can help me solve this problem?
The following is my code:
class Test{
private ...
0
votes
1
answer
41
views
How to call a method from a dynamically instantiated class in PHP?
I'm dinamically instantiating a class, but I want to know if there's a way to call a method from this instance, thanks
Code:
if(class_exists($class_name)){
$class = new $class_name;
$class....
0
votes
2
answers
37
views
get a dictionary of an attribute in all instances
class Players:
def __init__(self, username, score):
self.username = username
self.score = score
If I create a class and some instances of it with different scores, how can I get a dictionary ...
0
votes
1
answer
30
views
On Python, How to open multiple command windows simultaneously (in cascade)
I intend to monitor connectivity (by ping ) 3 devices into the net. So far I tried the follow scripts but in some, the commands run in a single windows
import os
import multiprocessing
def xxx():
...
0
votes
1
answer
78
views
Azure SQL MI - advantages of using a private endpoint
Seems like an easy question but since SQL MI already requires a subnet delegated to it, Why Would you use a private endpoint? You already have a private IP address which will keep traffic contained to ...
0
votes
1
answer
51
views
Java, get calling instance [duplicate]
Following example
public class C{
A myA;
public C(){
myA = new A();
}
}
public class A{
C myOrigin;
public A(){
// How to set myOrigin to the instance
...
4
votes
1
answer
50
views
Prevent creating a class only if shared pointer
how to prevent people from creating an instance of class, but only create a shared pointer? I am doing something like:
class OnlyShred
{
public:
friend std::shared_ptr<OnlyShred> make_shared(...
3
votes
3
answers
227
views
Create different instances of a class chain based on a field in the input request with Spring Boot
Every request that my Java application receives, passes through 4 layers:
Handler --> Validator --> Processor --> DAO
Handler is the API Resource. (Handler.java)
Validator validates the ...
0
votes
1
answer
124
views
How to automatically stop Sagemaker notebook instances if it is idle?
I have been looking for a script to automatically close Sagemaker Notebook Instances that have been forgotten to be closed or that are idle. A few scripts I found don't work very well (eg: link , it ...
0
votes
0
answers
32
views
Lua calling a methode on instance error attempt to call method 'getCategory' (a nil value)
first of all i am totaly new to LUA so i dont know the right term so sorry for that.
Now to my problem.
I got a class which has a methode getCategory. The code of this class is closed source so i cant ...
0
votes
0
answers
29
views
Why are the JavaScript primitives are not an instance of their constructors? [duplicate]
Here's a snapshot of what I've tested on the Firefox console. Why is; 'a instance of Number', gives false, while 'object instance of Object' is true? Does this mean, the variable "a" is a ...
0
votes
1
answer
63
views
How to share an instance variable between multiple processes
I have a class defined and used as follows, that includes a method called in the context of a multiprocessing pool:
from multiprocessing import Pool
class MyClass:
def __init__(self, big_object):
...