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

Instance variable does not retain its value

I'm learning Objective-C right now and in order to practice I wrote a simple random maze generator for OS X, which works fine. Next I tried to add some more interaction with buttons, but I'm having trouble with the instance variables as they don't…
Arya
  • 11
  • 2
1
vote
1 answer

Python OOP: create an object that is an instance of multiple classes

Say I built some classes containing some instance methods: class A: def func_of_A(self): print("foo") class B: def func_of_B(self): print("bar") How can I construct an object/variable c that is an instance of both A and B,…
Steve
  • 207
  • 1
  • 10
1
vote
1 answer

Using Builder Pattern, I got AttributeError: 'NoneType' object has no attribute to builder class function

I try to instance my class that made by using builder pattern class Cat: def __init__(self,height,weight, color): self.height = height self.weight = weight self.color = color def print(self): print("%d %d %s"…
Minseo Kim
  • 13
  • 3
1
vote
2 answers

Looping through attributes within Class instances?

I am trying to simulate a baseball game to learn more about python and programming in general... I ran into an interesting learning point in programing... and was wondering if someone could explain this error... import random rosterHome =…
1
vote
6 answers

How can I get a list of instances of a class

Possible Duplicate: Get all instances of a class in PHP If I have a class and create a number of instances of that class, is there a way for me to retrieve a full list of those instances via PHP? I'm using PHP 5.3.6.
Ralph M. Rivera
  • 769
  • 3
  • 12
  • 25
1
vote
2 answers

Using instance method to concatenate a list

I have a class named stock, and I am trying to concatenate quarterly earnings for an object. class Stock : def __init__(self,name,report_date,earning,estimate): self.Name = name self.Report_date = report_date self.Earning…
Inkyu Kim
  • 97
  • 5
1
vote
0 answers

Do we need retry logic for AWS EC2 instance metadata api calls?

When obtaining the instance region from the AWS EC2 instance metadata service we have seen a call return 403 not found. This behaviour is not common but when it does happen the instance won't launch correctly as the userdata script relies on knowing…
Leslie Alldridge
  • 1,427
  • 1
  • 10
  • 26
1
vote
2 answers

Is there anything wrong with importing a python module into a routine or class definition?

Possible Duplicate: Should Python import statements always be at the top of a module? I recently answered a SO question and provided this routine as a solution: def set_fontsize(fig,fontsize): import matplotlib """ For each text…
Yann
  • 33,811
  • 9
  • 79
  • 70
1
vote
2 answers

Unique instances of Javascript self-executing anonymous functions

I have created the PHP side of a modular AJAX/PHP framework and now I am trying to implement the client side. From my previous experience with modular web applications I know that sometimes multiple instances of one particular module are needed. For…
JustAMartin
  • 13,165
  • 18
  • 99
  • 183
1
vote
0 answers

Instance error Django Test models.py AttributeError: 'NoneType' object has no attribute

I am performing a Django test case for models.py file the models.py file looks like import sys from datetime import datetime from dateutil.relativedelta import relativedelta from django.apps import apps from django.conf import settings from…
1
vote
1 answer

Dart Object instantiating

I'm very new to programming and Dart. I was wondering why you put Response in front of the variable response. Also why do we use Datetime object in front of the variable 'now?' I believe when you want to instantiate, you write Datetime now =…
1
vote
1 answer

Abaqus check instance name

I am using python in Abaqus to print coordinates of specific nodesets. I am currently able to find the nodelabel, and x-y-z coordinates of each printed node. I also would like to print the instance (or nodeset) name each node belongs to, so I can…
JetskiS
  • 31
  • 4
1
vote
1 answer

If I replace the only reference to an instance of a class in an array, does it destroy the original instance?

I am trying to create a grid based map by instancing a class associated with each tile, and storing them in an array. The GenerateBattlefieldTiles() method simply generates an entire map of generic tiles, which will be replaced with later methods.…
1
vote
1 answer

Python prevent multiple-instances / tkinter instance

Python 3.10 (OS Windows 10, 64 bit) Hi, I compiled my Python tkinter code. When I run the *.exe twice there are two tkinter main windows (the same as when I'd run the windows notepad.exe twice). But I want to prevent the tkinter .exe can be started…
Werner925
  • 39
  • 3
1
vote
1 answer

How to convert an Amazon EC2 instance for use with Auto Scaling?

I have 1 perfect AWS EC2 instance in working condition which is running NODE js which have its elastic IP. Now I need to auto-scale if that instance in use over 80%. I do know few ways to do that but am not able to figure out, when new instance…