Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About getattr()
#6
(Mar-11-2019, 02:50 AM)ichabod801 Wrote:
(Mar-11-2019, 02:35 AM)MingyuanLuo Wrote: The default argument has None as default value.

Where are you getting that from? It's not in the documentation. The documentation describes the behavior of getattr as Yoriz did, and as you saw.

I saw and understand the documentation. But I saw this in builtins.py
def getattr(object, name, default=None): # known special case of getattr
    """
    getattr(object, name[, default]) -> value
    
    Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
    When a default argument is given, it is returned when the attribute doesn't
    exist; without it, an exception is raised in that case.
    """
    pass
Reply


Messages In This Thread
About getattr() - by MingyuanLuo - Mar-10-2019, 06:48 AM
RE: About getattr() - by Yoriz - Mar-10-2019, 08:30 AM
RE: About getattr() - by MingyuanLuo - Mar-11-2019, 02:35 AM
RE: About getattr() - by ichabod801 - Mar-11-2019, 02:50 AM
RE: About getattr() - by MingyuanLuo - Mar-20-2019, 10:35 AM
RE: About getattr() - by perfringo - Mar-11-2019, 08:41 AM
RE: About getattr() - by MingyuanLuo - Mar-20-2019, 11:41 AM
RE: About getattr() - by ichabod801 - Mar-20-2019, 01:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  question about getattr() ryfoa6 3 2,197 Apr-07-2020, 07:16 PM
Last Post: deanhystad
  Vars and getattr problem catosp 5 4,081 Aug-28-2018, 02:54 PM
Last Post: buran

Forum Jump:

User Panel Messages

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