Questions tagged [instance]

In object-oriented programming an instance is an occurrence or a copy of an object, whether currently executing or not.

Instances of a class share the same set of attributes, yet will typically differ in what those attributes contain. For example, a class "Employee" would describe the attributes common to all instances of the Employee class. For the purposes of the task being solved Employee objects may be generally alike, but vary in such attributes as "name" and "salary".

Related tags:

5388 questions
1
vote
1 answer

Instancing with export variables not working, so, not able to clone scenes by adding other scenes as a child of the Main

I am coding a star collect game in Godot, but while trying to add a scene as a child of the main (The scene which starts first, and the scene where I am doing the instancing), it's not working, rather the debug screen lags so much that it shows "Not…
1
vote
0 answers

Is there a limit to the number of remote filesystemwatcher (.NET library) instances you can create?

I am using the .NET filesystemwatcher class to monitor files on disk. I'm writing a program that is supposed to watch a shared folders from numerous remote machines. I've been testing a bunch and have confirmed that I can get events from shared…
1
vote
4 answers

Different instances of A in B (Python)

In a situation like this b1 and b2 both have the same instanse of A. class A: def __init__(self): self.var=1 class B: a=A() def __init__(self): pass b1=B() b2=B() b1.a.var=2 #changing "var" in b1 would also change it…
Stals
  • 1,543
  • 4
  • 27
  • 52
1
vote
1 answer

WooCommerce custom shipping rate with cost at product level

I want to create several shipping rates in WooCommerce, based on a different fixed cost per product, which I'm saving as meta values. I'd like to offer a different selection of rates for each of my shipping zones: for example, in the UK I'd like to…
And Finally
  • 5,602
  • 14
  • 70
  • 110
1
vote
0 answers

How to create a new instance of Grid,populate that grid with the entities and return that grid

I am trying to create a new instance of Grid, populate that grid with the entities and return that grid. what I've done as code: class MapLoader: """ds""" def load(self, filename:str)->Grid: with open(filename) as map_file: …
Zerone
  • 127
  • 1
  • 12
1
vote
2 answers

How to kill an instance of an application

I am having a text file in this path "C:\Test\test.txt" when this was openeed I need to close this. When I am trying to use the below code all the instances of notepad are closing and I don't want that to be happened and I want to close only the…
user676589
1
vote
1 answer

Formatting class instance return (list)

I'm having difficulty with formatting when an instance that is a list is printed. If I defined a class and created a class instance as the following: class Building(): def __init__(self): self.rooms = [] def add_room(self, rm_num:…
Judy
  • 13
  • 3
1
vote
1 answer

Are __dict__ and __weakref__ the default slots at class definition?

According to the Python language documentation: __slots__ allow us to explicitly declare data members (like properties) and deny the creation of __dict__ and __weakref__ (unless explicitly declared in __slots__ or available in a parent.) So I am…
Géry Ogam
  • 6,336
  • 4
  • 38
  • 67
1
vote
1 answer

Vulkan: vkGetPhysicalDeviceSurfaceCapabilitiesKHR returning VK_ERROR_SURFACE_LOST_KHR in C

I have this function: static cyBool swapchainSuitable(VkPhysicalDevice device, VkSurfaceKHR surface){ //Capabilities VkSurfaceCapabilitiesKHR capabilities; VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface,…
I NN_
  • 139
  • 6
1
vote
1 answer

arrays disappearing in method scope

I am trying to create a class to my javascript game to add multiplayer but within the class i am having problems with the values of arrays changing as you can see in the sendNetEntities() function class NET_IO{ //probably put address here …
Nik Hendricks
  • 244
  • 2
  • 6
  • 29
1
vote
0 answers

fabricjs fabric.util.object.clone problem after clone

Im trying to deep clone an instance of simple objects and group with fabric using fabric.util.object.clone however, the behavours are not consistant and really strange. heres an example link to jsfiddle(https://jsfiddle.net/EYBTM/pxz3bq2w/21/) the…
1
vote
1 answer

instance methods sharing in python

1- is it true? all the objects of a particular class have their own data members but share the member functions, for which only one copy in the memory exists? 2- and why the address of init in this code is similar: class c: def…
mim
  • 11
  • 2
1
vote
0 answers

Python setter and getter for class attributes

There are situations when I need to set class attributes from within an instance. One solution would be to create a class method that is called the instance method. That class method would be used to set the class attribute. However, I would like to…
user1315621
  • 3,044
  • 9
  • 42
  • 86
1
vote
2 answers

How do I correctly implement an instance Eq for a data type with constructors?

I am implementing an instance Eq for MyNum data type that has Fractions and Mixed Numbers as data constructors (each one with its own arguments). I am also using a helper function to convert from MyNum to Rational. This should help me reduce…
stcol
  • 131
  • 1
  • 11
1
vote
2 answers

Why calling class function from a thread works in Java?

So I got this weird scenario that works fine but doesn't make any sense as to why it works. From my experience in C++, I'm very sure that this will not work at all and will throw an error during compilation. public class Practice { private void…
M. Ather Khan
  • 305
  • 1
  • 2
  • 9
1 2 3
99
100