unsubscribe

Mark Jordaan markguildwars1 at hotmail.com
Wed Dec 17 03:54:54 CET 2008


> From: p.f.moore at gmail.com> Subject: Re: Does Python3 offer a FrozenDict?> Date: Tue, 16 Dec 2008 09:56:57 -0800> To: python-list at python.org> > On 16 Dec, 17:28, bearophileH... at lycos.com wrote:> > Johannes Bauer:> >> > > is there anything like a frozen dict in Python3, so I could do a> > > foo = { FrozenDict({"a" : "b"}): 3 }> >> > You can adapt this code to Python3 (and post a new recipe? It may be> > positive to create a new section of the Cookbook for Py3 only):http://code.activestate.com/recipes/414283/> > There's actually only tiny changes needed (I believe)> - Change exception syntax: raise AttributeError("A frozendict cannot> be modified.")> - (bugfix for the original version): add **kw arg to __new__ (passed> to dict.__init__)> > Simple testing looks OK. And the resulting code is OK for both 2.x and> 3.0.> > Moral - don't assume that all code needs to be rewritten for Python> 3.0 :-)> > Paul.> > PS I imagine that 2to3 would have fixed this up fine, but it was so> easy to do by hand that I didn't bother :-)> --> http://mail.python.org/mailman/listinfo/python-list
_________________________________________________________________
Get the next generation of Free Windows Live Services
http://get.live.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081217/6db07a2a/attachment.html>


More information about the Python-list mailing list