Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion python bijection

Path: g2news1.google.com!postnews.google.com!x31g2000yqx.googlegroups.com!not-for-mail
From: Francis Carr <coldtort...@gmail.com>
Newsgroups: comp.lang.python
Subject: Re: python bijection
Date: Fri, 27 Nov 2009 10:12:36 -0800 (PST)
Organization: http://groups.google.com
Lines: 12
Message-ID: <f4536bb0-80ab-4487-83f8-b41542fd0494@x31g2000yqx.googlegroups.com>
References: <b8d5040d-920c-4dd2-82c3-de5cb5cfd52e@j19g2000yqk.googlegroups.com> 
	<5a99def7-e182-4782-9054-f1035affa34d@x5g2000prf.googlegroups.com> 
	<aae2d082-1ca3-4304-b178-bf59012692f6@e31g2000vbm.googlegroups.com> 
	<7n39ojF3jj6iuU1@mid.individual.net> <12c55890-118d-4655-b6c0-c908c9734a17@a32g2000yqm.googlegroups.com> 
	<baa40af2-c9f4-4c24-bc1f-92563872384d@x16g2000vbk.googlegroups.com>
NNTP-Posting-Host: 173.76.102.218
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1259345557 25447 127.0.0.1 (27 Nov 2009 18:12:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 27 Nov 2009 18:12:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: x31g2000yqx.googlegroups.com; posting-host=173.76.102.218; 
	posting-account=4MSGSgoAAACUBhFJ8W-bad0BLGNANDes
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; 
	rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5,gzip(gfe),gzip(gfe)

I was really inspired by this discussion thread! :-)

After much tinkering, I think I have a simpler solution.  Just make
the inverse mapping accessible via an attribute, -AND- bind the
inverse of -THAT- mapping back to the original.  The result is a
python dict with NO NEW METHODS except this inverse-mapping
attribute.  I have posted it on code.activestate.com as <a
href="http://code.activestate.com/recipes/576968/">Recipe 576968:
Flipdict -- python dict that also maintains a one-to-one inverse
mapping</a>

 -- F. Carr