Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

FrozenJSON #20

@xiaochuntu

Description

@xiaochuntu

example 19-5 FrozenJSON

def __init__(self, mapping):
        self.__data = dict(mapping)  ➊

    def __getattr__(self, name):  ➋
        if hasattr(self.__data, name):
            return getattr(self.__data, name)  ➌
        else:
            return FrozenJSON.build(self.__data[name])  ➍

self.__data is a dict ,function hasattr(object, name) the first parameter is object,so hasattr(self.__data, name) always return False,so step ➌ never return . am i right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy