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?
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…
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 The function getAttribute("class") works…
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…
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() +…
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…
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…
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…
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
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…

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 …
Claudiu
  • 206,738
  • 150
  • 445
  • 651
5
votes
0 answers

Why frameElement is null?

I have problem with access to an iframe attribute from inside the iframe.