GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Inaccurate emulation of _PyType_Lookup() in the Descriptor HOWTO · Issue #95822 · python/cpython Closed Labels docsDocumentation in the Doc dirDocumentation in the Doc dir DescriptionDocumentationDoc link: https://docs.python.org/3.10/howto/descriptor.html#invocation-from-an-instance The code example is bad at https://github.com/python/cpython/blame/eb81c1aea16914347919745e843c982ed831a9fb/Doc/howto/descriptor.rst#L589
Code Snippet: class A: def __get__(self, obj, objtype): return obj, objtype class B: a = A() print(B().a) # (<__main__.B object at 0x7ff56d0915e0>, <class '__main__.B'>) print(B.a) # same as getattr # (None, <class '__main__.B'>) SolutionUsing print(vars(B)['a']) # <__main__.A object at 0x7ff56cfef2b0> Activity
MetadataMetadataAssigneesLabelsdocsDocumentation in the Doc dirDocumentation in the Doc dir ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |