Questions tagged [class-attributes]
170 questions
0
votes
2 answers
python class attribute cannot used as an argument for constructor?
In python 3 I found that class attribute can be used as a argument in __init__() function, like below:
file test.py:
class Foo:
var1 = 23333
def __init__(self, var=var1):
self.var = var
run in cmd:
C:\Users\rikka\Desktop>py -3 -i…

michael huang
- 35
- 4
0
votes
1 answer
Decorated class looses acces to its attributes
I implemented a decorator that worked like a charm until I added attributes to the decorated class. When I instantiate the class, it cannot acces the calss attributes. Take the following minimal working example :
from module import…

Felipe Aguirre
- 218
- 1
- 12
0
votes
2 answers
How to extend a class array/ call class array attributes after extend a class?
for a larg-DB based dynamically-multiple-area-menu, I created a class MenuPoint:
class MenuPoint{
public int areaId;
public int preID;
public String name;
public String desc;
public String stepInImg = "bsp.img";
public String stepOutImg =…

xXTobiXx
- 17
- 5
0
votes
2 answers
Javascript: Printing class attributes
I got a class in css :
img {
position: relative;
left: 0;
top: 0;
}
and an img in the HTML body. I can move the img with my JQuery/Javascript code:
$('img').animate({left: "-=20"}, 'fast');
Now I want to print out the attribute…

FrontMobe
- 186
- 1
- 13
0
votes
2 answers
class attributes in c#
I need your help.
I have read about the class attributes in C# and I understood that we use them for authorization, authentication or to get some information about the class when you use reflection in the reverse process.
but really I want to…

Mo Haidar
- 3,748
- 6
- 37
- 76
0
votes
1 answer
Python 3.3 Class method not working, why?
Hi below is the relevant code for my problem:
class Player:
def __init__(self, name, x, y, isEvil):
self.health = 50
self.attack = randint(1, 5)
self.name = name
self.x = x
…

Coned_Stoding
- 135
- 1
- 3
- 10
0
votes
3 answers
Share class attributes among several classes in Python
I have a class that contains class attributes. I need that they are shared as class attributes by a group of other classes, so that if any of them modifies those attributes, they are modified for all of them. I naively tried it using inheritance,…

zeycus
- 860
- 1
- 8
- 20
0
votes
2 answers
Base class class variable values in Python
If I want to make a base class that other classes will inherit from, but will never use the class variables from, what should I set the class variables to?
For example:
class Spam:
time_to_cook = None
def eat(self):
...
class…

rlms
- 10,650
- 8
- 44
- 61
0
votes
1 answer
Subtle unexpected behaviour with a function used as class-attribute
I have a piece of code that was broken when I changed an attribute and made it class-attribute, I would love to understand why.
So, I started with
def linInterp(x1, x2, y1, y2, x):
return y1 + (x - x1) * (y2 - y1) / (x2 - x1)
class…

zeycus
- 860
- 1
- 8
- 20
0
votes
1 answer
Sharing attributes among objects that can be used in decorated methods
I have a group of objects which are instances of the same class. I would like them to share a common attribute.
Ok, I can simply define a class attribute:
MyClass():
classattr = None
def __init__(self):
self.instattr = None
but, I…

jramm
- 6,415
- 4
- 34
- 73
0
votes
1 answer
Making a class attribute into a string
I know what the problem is, i just don't know how to fix it. I've googled how to make a class attribute into a string and I can't find anything. I know it's trying to add a class attribute to a string but how do I make self.mystring into a string so…

ShadyBears
- 3,955
- 13
- 44
- 66
0
votes
2 answers
Passing object instance data to Attribute
I would like to pass certain data from an instance of an object to its attribute, and I have troubles inderstanding how to implement it. Here's a sample:
[AuthenticateAttribute]
public class MyController: Controller
{
UserInfo info;
}
The idea…

Andy
- 2,670
- 3
- 30
- 49
0
votes
4 answers
Possibility of Implementing Minimize-to-Tray in C# in an Attribute
Attributes are awesome. But is it possible to create a C# attribute class that, when tagged, makes your application minimize to the system tray?
Technically, the attribute would need to be placed on the class of the main form. Once the user clicks…

ashes999
- 35
- 1
- 3
-1
votes
1 answer
Python global class attributes
I want to create a baseclass that has an attribute which should not change. Any derived class from this baseclass should have this attribute aswell. My idea was:
class baseclass(object):
flag = "some attr for all classes"
def __init__(self,…

Torilla
- 383
- 5
- 16
-1
votes
1 answer
AttributeError: type object 'lyssna' has no attribute 's'
I want to access one class attribute s and split it into 2 strings in another class. Any tips?
class lyssna:
def du():
s = '5-22'
class Fixish():
strt, stpp = lyssna.s.split('-')

aleckzz
- 1