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

Create 2 different instances of a class that calls methods?

I managed to develop a program that simulates a food takeout ordering system. I've created the class Takeout and its functions that successfully takes my own input and prints out my order. My problem is trying to develop class instances that call…
Retrospect
  • 19
  • 2
1
vote
1 answer

GCP - Initate a shutdown to an instance after certein time when it started (for example 3 hours after started)

I have instances in GCP. I can schedule a time to start and stop using the scheduler. But, I don't want a specific time of the day, I want a specific time after instance was started. For example - Stop the instance after 8 hours the instance is up…
1
vote
1 answer

Differents in static methods and non static methods in classes without fields

Someone once wrote: The space required for an instance depends only on the fields. The methods require memory too but only one time per class. Like static fields. That memory is allocated when the class is loaded. But what happens if a class…
MIkey
  • 21
  • 1
  • 2
1
vote
3 answers

Test if instances are from the same class

I've got a main "abstract" class Pet, and two "real" classes Dog and Cat. When I've got two instances of pets, I want to know if they are the "same kind of pets" without taking care of what kind of pets they are. I tried…
Phantom
  • 833
  • 1
  • 9
  • 26
1
vote
1 answer

Why PyCallable_Check() returns 0 on global class instances?

Rigth now I'm working on embedding python into a larger C++ application. Despite I'm not a python specialist, I understand that with the builtin PyCallable_Check() I can check if a python object is actually callable. From What is a "callable"? I…
dom
  • 35
  • 5
1
vote
0 answers

axios instance not hitting both request and response interceptor

My axios instance is only hitting either the request interceptor or the response but not both. Take the following as an example. const axiosInstance = axios.create({ baseURL: GATEWAY_URL, headers:…
user10045300
  • 387
  • 1
  • 4
  • 14
1
vote
1 answer

How can I do AWS EC2 instance auto scale down in night (stop & change to t2.small) and automatic scale up (stop & go to t2.large) in morning?

I am looking AWS EC2 autoscaling feature that can automatically stop my EC2 instance at night and change my instance type (i.e: t2.xlarge to t2.small) for the whole night and in the morning again stop EC2 instance and change instance type (i.e…
1
vote
1 answer

Google Cloud Functions minInstances Pricing

Is there any pricing information regarding deploying cloud functions with minInstances greater than 0? Also, when I deployed the function with runWith({ minInstances: 1}), the edit function page at console.cloud.google.com does not reflect the…
Shaun
  • 131
  • 5
1
vote
2 answers

Table of Objects in Lua

I'm attempting to create a Lua object like this Block = {x = 0, y = 0, color = "red"} function Block:new (x, y, color) block = {} setmetatable(block, self) self.__index = self self.x = x self.y = y self.color = color return…
Matt Mohandiss
  • 145
  • 2
  • 10
1
vote
1 answer

Dice Roller Values

I am creating a dice rolling application with java. I have a "Die" class that rolls a single die, and a "Dice" class that uses multiple instance variable of "die". However, it only returns 0 for my values. The Die class on its own works and will…
Ben
  • 37
  • 4
1
vote
2 answers

Can you initialise multiple instances of a class in one single line?

Imagine I would like to compact my code when initialising several instances of a class. This code works: from ipywidgets import Output,HBox out1 = Output(layout={'border': '1px solid black'}) out2 = Output(layout={'border': '1px solid black'}) out3…
JFerro
  • 3,203
  • 7
  • 35
  • 88
1
vote
1 answer

The instance relation between type and object in python?

Show class relation between type and object: issubclass(type,object) True issubclass(object,type) False It is clear that type derived from object,object is the father class of type,type is the son class of…
showkey
  • 482
  • 42
  • 140
  • 295
1
vote
2 answers

Passing instances to object vs adding instance as attribute later

I have a case where my object sometimes has an associated object and other times does not. e.g. my car sometimes has cruise control, and other times does not. There are two patterns I am debating between - passing an instance, or adding this later.…
Tminer
  • 302
  • 2
  • 4
  • 14
1
vote
1 answer

How to define different addresses for class attributes and instance attributes?

How to define different addresses for class attributes and instance attributes? This problem has bothered me for a long time, unless I delete the definition of the class attribute, but want to use the class attribute. I have defined a dict with the…
jaried
  • 632
  • 4
  • 15
1
vote
1 answer

flow of code from view to serializer class in django rest framework

I am trying to understand the code flow in Django rest framework from view class to serializer class. Like we know if we create an object of a class, the class gets instantiate with that object. And if there are other functions inside that class, we…
Reactoo
  • 916
  • 2
  • 12
  • 40