Re: cannot create my own dict

2007-09-20 Thread David
> The reason for this problem is that we are busy re-structuring a large Python > program, and we want to ensure nobody is messing up our data structures (at > least not until we are finished). python-egenix-mxproxy (Debian package name) may be useful. http://www.egenix.com/products/python/mxBase

Re: cannot create my own dict

2007-09-20 Thread John J. Lee
"A.T.Hofkamp" <[EMAIL PROTECTED]> 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 sta

Re: cannot create my own dict

2007-09-19 Thread A.T.Hofkamp
On 2007-09-19, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > A.T.Hofkamp a écrit : >> So if copying all methods of a native dictionary is not enough, what should I >> do to make my class work as a dictionary WITHOUT deriving from dict (which >> will >> obviously work). >> Hello all, Thanks fo

Re: cannot create my own dict

2007-09-19 Thread Steven D'Aprano
On Wed, 19 Sep 2007 21:43:59 +0200, Bruno Desthuilliers wrote: >> So if copying all methods of a native dictionary is not enough, what >> should I do to make my class work as a dictionary WITHOUT deriving from >> dict (which will obviously work). >> >> > Sorry, I missed this last requirement. BT

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
A.T.Hofkamp a écrit : > Hello all, > > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > (snip) > So if copying all methods of a native dictionary is not enough, what should I > do to make my class work as a

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > A.T.Hofkamp a écrit : > (snip) >> # Below is produced with >> # print '\n'.join(['self.%s = self.mydict.%s' % (v,v) >> # for v in dir(dict)]) >> # commented-out functions done by hand >> # >> #self.__class__ =

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
Steve Holden a écrit : > A.T.Hofkamp wrote: > (snip) >> So if copying all methods of a native dictionary is not enough, what >> should I >> do to make my class work as a dictionary WITHOUT deriving from dict >> (which will >> obviously work). >> > You have to overwrite the "__new__" method to r

Re: cannot create my own dict

2007-09-19 Thread Bruno Desthuilliers
A.T.Hofkamp a écrit : > Hello all, > > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > > Below is a brute-force experiment that cannot deal with "x in obj", plz read > the explanation below the code: >

Re: cannot create my own dict

2007-09-19 Thread Peter Otten
A.T.Hofkamp wrote: > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > > Below is a brute-force experiment that cannot deal with "x in obj", plz read > the explanation below the code: > --

Re: cannot create my own dict

2007-09-19 Thread Steve Holden
A.T.Hofkamp wrote: > Hello all, > > This morning I tried to create my own read-only dictionary, and failed > miserably. > I don't understand why, can somebody enlighten me? > > Below is a brute-force experiment that cannot deal with "x in obj", plz read > the explanation below the code: > ---

cannot create my own dict

2007-09-19 Thread A.T.Hofkamp
Hello all, This morning I tried to create my own read-only dictionary, and failed miserably. I don't understand why, can somebody enlighten me? Below is a brute-force experiment that cannot deal with "x in obj", plz read the explanation below the code: class myown