Questions tagged [getattribute]
284 questions
466
votes
8 answers
Difference between __getattr__ vs __getattribute__
I am trying to understand when to use __getattr__ or __getattribute__. The documentation mentions __getattribute__ applies to new-style classes. What are new-style classes?
![](../../users/profiles/165673.webp)
Yarin
- 144,097
- 139
- 361
- 489
226
votes
4 answers
Understanding the difference between __getattr__ and __getattribute__
I am trying to understand the difference between __getattr__ and __getattribute__, however, I am failing at it.
The answer to the Stack Overflow question Difference between __getattr__ vs __getattribute__ says:
__getattribute__ is invoked before…
![](../../users/profiles/225312.webp)
user225312
- 108,033
- 64
- 161
- 179
99
votes
3 answers
How to get attribute of element from Selenium?
I'm working with Selenium in Python. I would like to get the .val() of a
![](../../users/profiles/194000.webp)
Richard
- 52,447
- 93
- 287
- 475
17
votes
2 answers
Use cases for property vs. descriptor vs. __getattribute__
The question refers to which one is preferable to be used in which use case, not about the technical background.
In python, you can control the access of attributes via a property, a descriptor, or magic methods. Which one is most pythonic in which…
![](../../users/profiles/1544277.webp)
Iodnas
- 3,154
- 20
- 25
15
votes
3 answers
How to get the value of an attribute in Javascript
I have this input line which I am trying to extract the text of the value attribute:
The function getAttribute("class") works…
![](../../users/profiles/905849.webp)
Tamara Caligari
- 419
- 3
- 11
- 27
13
votes
5 answers
Finding if element is visible (JavaScript )
I have a javascript function that tries to determine whether a div is visible and does various processes with that variable. I am successfully able to swap an elements visibility by changing it's display between none and block; but I cannot store…
![](../../users/profiles/1407020.webp)
Devon Bernard
- 2,140
- 4
- 17
- 31
12
votes
2 answers
python: cooperative supercall of __getattr__
I'm working with somethign similar to this code:
class BaseClass(object):
def __getattr__(self, attr):
return lambda:'1'
class SubClass(BaseClass):
def foo(self):
suffix = '2'
return super(SubClass, self).foo() +…
![](../../users/profiles/146821.webp)
bukzor
- 34,859
- 10
- 67
- 104
10
votes
4 answers
Using __getattribute__ or __getattr__ to call methods in Python
I am trying to create a subclass which acts as a list of custom classes. However, I want the list to inherit the methods and attributes of the parent class and return a sum of the quantities of each item. I am attempting to do this using the…
![](../../users/profiles/920253.webp)
AJ Medford
- 183
- 1
- 1
- 9
9
votes
2 answers
To use getAttribute(), or not to use getAttribute(): that is the question
Possible Duplicate:
JavaScript setAttribute vs .attribute=
javascript dom, how to handle "special properties" as versus attributes?
Many times, in forums or places such as Usenet I have been told by some (when criticizing my code) that instead of…
user912695
9
votes
1 answer
custom attribute works only with element.getAttribute("attribute") but not "element.attribute"
I have just noticed, that if I give a custom attribute to an html element, for example:
then i can retrieve it like…
![](../../users/profiles/1831096.webp)
Isti115
- 1,414
- 2
- 22
- 29
8
votes
5 answers
Selenium getText
I want to getText() using By.id or By.cssSelector.
I managed to solve my problem by doing getAttribute("value"), but I don't understand why getText() doesn't work like I expect it, and I might need it so all help is appreciated.
Here is the Java…
![](../../users/profiles/1486950.webp)
Lpgfmk
- 373
- 1
- 3
- 14
7
votes
1 answer
php DOM getAttribute
Alright, so I have an odd case here that I just can't figure out.
I want to parse a list on a website. The HTML looks somewhat like this:
- Blabla
- Blabla …
![](../../users/profiles/402747.webp)
clausvdb
- 586
- 2
- 5
- 12
6
votes
1 answer
Difference between .getAttribute and dataset in JS
I have been using .getAttribute and today found out about .dataset, so i was wondering what the differences are and when should each be used.
So here is an example. Let's say we have a paragraph:
some…
![](../../users/profiles/4649949.webp)
LuisBento
- 520
- 6
- 14
6
votes
2 answers
Is there any way to override the double-underscore (magic) methods of arbitrary objects in Python?
I want to write a wrapper class which takes a value and behaves just like it except for adding a 'reason' attribute. I had something like this in mind:
class ExplainedValue(object):
def __init__(self, value, reason):
self.value = value
…
![](../../users/profiles/15055.webp)
Claudiu
- 206,738
- 150
- 445
- 651