cannot create my own dict
John J. Lee
jjl at pobox.com
Thu Sep 20 21:23:56 CEST 2007
"A.T.Hofkamp" <hat at se-162.se.wtb.tue.nl> writes:
> I can derive from dict, but the problem with that is that I start with a
> read/write dictionary, and I can only hope to plug all holes to prevent my data
> from leaking out.
> By starting from 'object', I certainly don't have that problem, I start with a
> closed bucket and punch holes in it in a controlled way.
> (I rather have the program drop dead due to not having enough access than
> have it continue with too much access causing havoc 500 statements later in a
> totally unrelated area.)
> Rather than write a bunch of code like
> def __contains__(self, val):
> return val in self.mydict
> I thought I'd simply do
> self.__contains__ == self.d.__contains__
> which is exactly the same but less work (or so I thought), and possibly
> slightly faster.
> Well, no such luck thus :-(
More information about the Python-list