Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


adp001 posted Thu, 14 May 2020 at 9:41 AM

Above dict replacement delivers None for not existent elements. If you want original behaviour, use this a bit slower class:

class MyDict(dict):
    def __getattr__(self, item):
        if not item.startswith("_") and item in self:
            return self.get(item)
        return super(self.__class__, self).__getattribute__(item)