Questions tagged [class-attributes]
170 questions
                    
                    474
                    
            votes
                
                24 answers
            
        React Js conditionally applying class attributes
I want to conditionally show and hide this button group depending on what is passed in from the parent component which looks like this:
    
         
    
    
        apexdodge
        
- 6,657
- 4
- 26
- 33
                    171
                    
            votes
                
                4 answers
            
        How to document class attributes in Python?
I'm writing a lightweight class whose attributes are intended to be publicly accessible, and only sometimes overridden in specific instantiations.  There's no provision in the Python language for creating docstrings for class attributes, or any sort…
         
    
    
        intuited
        
- 23,174
- 7
- 66
- 88
                    145
                    
            votes
                
                3 answers
            
        Explain __dict__ attribute
I am really confused about the __dict__ attribute. I have searched a lot but still I am not sure about the output.
Could someone explain the use of this attribute from zero, in cases when it is used in a object, a class, or a function?
         
    
    
        Zakos
        
- 2,448
- 4
- 16
- 20
                    43
                    
            votes
                
                5 answers
            
        Why don't my subclass instances contain the attributes from the base class (causing an AttributeError when I try to use them)?
I have this base class and subclass:
class Event:
    def __init__(self, sr1=None, foobar=None):
        self.sr1 = sr1
        self.foobar = foobar
# Event class wrappers to provide syntatic sugar
class TypeTwoEvent(Event):
    def __init__(self,…
         
    
    
        Homunculus Reticulli
        
- 65,167
- 81
- 216
- 341
                    32
                    
            votes
                
                4 answers
            
        python: What happens when class attribute, instance attribute, and method all have the same name?
How does python differentiate a class attribute, instance attribute, and method when the names are the same?
class Exam(object):
    test = "class var"
    def __init__(self, n):
        self.test = n
    def test(self):
        print "method :…
         
    
    
        naren
        
- 14,611
- 5
- 38
- 45
                    23
                    
            votes
                
                3 answers
            
        Python - function as class attribute becomes a bound method
I noticed that if I define a class attribute equal to a function when I create an instance of that class the attribute becomes a bound method. Can someone explain me the reason of this behaviour?
In [9]: def func():
   ...:     pass
   ...: 
In…
         
    
    
        se7entyse7en
        
- 4,310
- 7
- 33
- 50
                    21
                    
            votes
                
                3 answers
            
        Dynamically create class attributes
I need to dynamically create class attributes from a DEFAULTS dictionary.
defaults = {
    'default_value1':True,
    'default_value2':True,
    'default_value3':True,
}
class Settings(object):
    default_value1 =…
         
    
    
        xyz-123
        
- 2,227
- 4
- 21
- 27
                    17
                    
            votes
                
                6 answers
            
        How to select element has class start and end with specific string using jquery?
I got several divs using classes like
.wrap-1-addon-1
.wrap-2-addon-1
.wrap-3-addon-1
I want to select all of them and use if ( $(this).hasClass() ) to check if its one of them. Currently I only do check for a single class. How can I check all of…
         
    
    
        Marian Rick
        
- 3,350
- 4
- 31
- 67
                    17
                    
            votes
                
                2 answers
            
        Class attribute evaluation and generators
How exactly does Python evaluate class attributes?  I've stumbled across an interesting quirk (in Python 2.5.2) that I'd like explained.
I have a class with some attributes that are defined in terms of other, previously defined attributes.  When I…
         
    
    
        AFoglia
        
- 7,968
- 3
- 35
- 51
                    14
                    
            votes
                
                6 answers
            
        React conditional classnames using template strings and && operator
There have been many questions on StackOverflow relating to applying conditional classnames to React components; however, I have not seen a good answer for this particular situation:
I have a basic div that I want to conditionally apply the…
         
    
    
        Drew Jex
        
- 845
- 2
- 13
- 24
                    14
                    
            votes
                
                3 answers
            
        Can I mark a class as not my code so the debugger steps over it?
I have a utility class that has been thoroughly tested, and I do not want the VS debugger to step into any of its methods. I think I have heard of a way to mark something as not my code so that the Just My Code debugger setting causes the debugger…
         
    
    
        Mark Avenius
        
- 13,679
- 6
- 42
- 50
                    14
                    
            votes
                
                6 answers
            
        Overwriting the class on a `Html.EditorFor`
by the default with 
<%: Html.EditorFor(m => m.ConfirmationHeadline) %>
the output is:
 
As you can see, the input…
         
    
    
        balexandre
        
- 73,608
- 45
- 233
- 342
                    11
                    
            votes
                
                3 answers
            
        How to use SQLAlchemy with class attributes (and properties)?
Say I'm making a game with items in it (think about Minecraft, CS:GO weapons, LoL and Dota items, etc.). There can be huge amounts of the same item in the game with minor detail differences like the condition/durability or the amount of ammo…
         
    
    
        Markus Meskanen
        
- 19,939
- 18
- 80
- 119
                    11
                    
            votes
                
                3 answers
            
        Python: Inheritance of a class attribute (list)
inheriting a class attribute from a super class and later changing the value for the subclass works fine:
class Unit(object):
    value = 10
class Archer(Unit):
    pass
print Unit.value
print Archer.value
Archer.value = 5
print Unit.value
print…
         
    
    
        Sano98
        
- 419
- 2
- 7
- 17
                    9
                    
            votes
                
                2 answers
            
        Python DocString (Google Style): How to document class attributes?
I have this small example:
"""Sandbox module"""
class Toto:
    """
    This class is an example
    Attributes:
        class_attribute (str): The class attribute #Unresolved reference
        instance_attribute (str): The instance attribute #OK
…
         
    
    
        Milan
        
- 1,547
- 1
- 24
- 47