Linked Questions

17 questions linked to/from python class attribute
2 votes
1 answer
2k views

I have a class Employee with a class variable raise_amount. I created two instances, emp_1 & emp_2, for this class. This question is not asking, what is a class variable, or how class variables ...
2 votes
3 answers
589 views

I have changed the value of class variable raise_amount for one instance. Later I have changed the value of the class variable with the classmethod set_raise_amt but it could not change the value for ...
0 votes
0 answers
274 views

I have the following code: receps =[1,1,1,2,2,2,2,3,3,3,3,3,3] listRecep = [] listNumRecep = [] class Line: def __init__(self,recep) : self.recep = recep class Recep: recep=&...
0 votes
0 answers
85 views

I am new to Python programming and I was coding the following script to increase my understanding of Pyhton OOP. # Python OOP class Employee: num_of_emps = 0 raise_amt = 1.04 def ...
2630 votes
27 answers
1.8m views

How do I create class (i.e. static) variables or methods in Python?
20 votes
5 answers
2k views

I am trying to reproduce the reactive extensions "shared" observable concept with Python generators. Say I have an API that gives me an infinite stream that I can use like this: def my_generator(): ...
6 votes
7 answers
3k views

There is this code: class Sample: variable = 2 object1 = Sample() object2 = Sample() print object1.variable # 2 print object2.variable # 2 object1.variable = 1 print object1.variable # 1 print ...
scdmb's user avatar
  • 15.7k
3 votes
2 answers
3k views

Are there any differences between a class variable and an instance variable with a default value? (especially in terms of their behavior under "normal use", internally I suppose they most likely are ...
3 votes
1 answer
2k views

I asked about this yesterday, but I botched writing up my question so much that by the time I realized what I typed, all the replies were solutions to a different miss-worded problem I didn't have. ...
-1 votes
2 answers
2k views

To quote diveintopython, "You already know about data attributes, which are variables owned by a specific instance of a class. Python also supports class attributes, which are variables owned by ...
Mark's user avatar
  • 1,224
1 vote
2 answers
725 views

I'm only just starting to actually dabble seriously in Python, so it's possible this has a very easy answer, but at the moment I'm just dumbfounded. Here's the gist of what my code is: class deck: ...
user avatar
1 vote
4 answers
160 views

I setup a class and it accepts and prints out the variables fine in one if statement. class npc: #class for creating mooks def __init__(self, name): self.name = name def npc_iq (self,...
1 vote
2 answers
128 views

Two examples; class Foo1: something = 0 def __init__(self, n): self.something = n and class Foo2: def __init__(self, n): self.something = n Both classes seem to have the ...
ap0's user avatar
  • 1,173
1 vote
1 answer
84 views

Say that I have the following Python code: import sys class DogStr: tricks = '' def add_trick(self, trick): self.tricks = trick class DogList: tricks = [] def add_trick(...
0 votes
0 answers
142 views

I have a thread class (TransmitThread) written in python which takes few parameters and then starts transmitting to a device(NI USRP). I have a rest flask based webservice,which on rest request by ...

15 30 50 per page
1
2