 <p>I think this displays a problem with your model of storing the data. You probably want to be using a data structure like a set, not just attributes.</p> <p>For example:</p> <pre><code>items = {"milk", "yogurt", "bread", "umbrella"} stored = set() </code></pre> <p>Then just store the ones you want in the <code>stored</code> set. Sets have very fast performance for membership checks, so to check, you can simply do <code>"milk" in stored</code>, for example.</p> <p>If you really wanted to keep the interface you have, you could use <code>__getattr__()</code> to override the action you get upon asking for an attribute:</p> <pre><code>def ___getattr__(self, item): return item in self.stored </code></pre> <p>This will return <code>False</code> to anything not in the fridge, if you needed it to only respond to possible items, that could be easily done:</p> <pre><code>def ___getattr__(self, item): if item not in self.items: raise AttributeError return item in self.stored </code></pre> <p>Naturally, setting can be done too:</p> <pre><code>def __setattr__(self, item, value): if item in self.items: if value: self.stored.add(item) else: self.stored.remove(item) else: ... </code></pre> <p>An alternative to this would be a dict to <code>True</code>/<code>False</code> - I can't really say I think either is particularly better, one might suit your project more. Just use whatever works best for you.</p>