From 8e1237f90c2b618d638454d5fb4919e9caad25ca Mon Sep 17 00:00:00 2001 From: whut Date: Sun, 9 Oct 2022 19:02:36 -0500 Subject: [PATCH] add __contains__ --- src/confthing/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/confthing/__init__.py b/src/confthing/__init__.py index e381dd5..a3c9248 100644 --- a/src/confthing/__init__.py +++ b/src/confthing/__init__.py @@ -68,3 +68,9 @@ class Config: def __setitem__(self, path, value): self.set(path, value, self.clobber_subscript) + def __contains__(self, path): + try: + self.get(path, strict=True) + return True + except: + return False