Python Forum
what is the __dict__ object?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what is the __dict__ object?
#7
Obviously the call id(A.__dict__) allocates a new object of type mappingproxy, that is to say a smart pointer. You are printing the id of these smart pointers. In the examples above, when B.__dict__ is accessed, the mappingproxy created for A.__dict__ is already destroyed, so the same address is reused. If you keep a reference to the proxy, two different addresses are used
>>> x = A.__dict__
>>> y = B.__dict__
>>> id(x), id(y)
(140355706316360, 140355683451672)
Reply


Messages In This Thread
what is the __dict__ object? - by aaron1989041 - Mar-28-2018, 02:44 AM
RE: what is the __dict__ object? - by Larz60+ - Mar-28-2018, 05:53 AM
RE: what is the __dict__ object? - by snippsat - Mar-28-2018, 01:32 PM
RE: what is the __dict__ object? - by wavic - Mar-28-2018, 03:25 PM
RE: what is the __dict__ object? - by aaron1989041 - Mar-29-2018, 02:15 AM
RE: what is the __dict__ object? - by Gribouillis - Mar-29-2018, 05:18 AM
id() function is strange - by aaron1989041 - Mar-28-2018, 09:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __dict__ in math library akbarza 6 958 Sep-28-2023, 08:23 AM
Last Post: buran
  dict and __dict__ cls0724 1 2,693 Apr-05-2020, 07:45 PM
Last Post: Mateusz

Forum Jump:

User Panel Messages

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