Python Forum
what if __getattr__() can't find an attribute, either?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what if __getattr__() can't find an attribute, either?
#1
what if __getattr__() can't find an attribute, either? what should it do? return None?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
https://docs.python.org/3/reference/data..._getattr__ Wrote:object.__getattr__(self, name)
Called when the default attribute access fails with an AttributeError (either __getattribute__() raises an AttributeError because name is not an instance attribute or an attribute in the class tree for self; or __get__() of a name property raises AttributeError). This method should either return the (computed) attribute value or raise an AttributeError exception.
Skaperen likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,286 Aug-17-2021, 05:24 PM
Last Post: Franky77
  @property vs __set__ / __get__ and __setattr__ / __getattr__ okhajut 1 3,345 Jun-15-2021, 03:48 PM
Last Post: snippsat
  Object cannot find its attribute colt 6 3,475 Oct-09-2019, 12:30 AM
Last Post: ichabod801
  __getattr__ and type hint itaybardugo 0 2,647 Jul-04-2019, 09:50 PM
Last Post: itaybardugo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020