Re: Two mappings inverse to each other: f, g = biject()

2007-02-07 Thread Jonathan Fine
[EMAIL PROTECTED] wrote: A google search for biject.py and bijection.py produced no hits, so I suspect that this may not have been done before. There are few (good too) implementations around, but they are called bidict or bidirectional dicts. Sometimes I use this implementation, with few

Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Jonathan Fine
Hello As part of the MathTran project I found myself wanting to maintain a bijection between long names and short names. http://www.open.ac.uk/mathtran In other words, I wanted to have two dictionaries f and g such that f[a] == b g[b] == a are equivalent statements. A google search for

Re: Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Nick Vatamaniuc
On Feb 6, 5:22 am, Jonathan Fine [EMAIL PROTECTED] wrote: Hello As part of the MathTran project I found myself wanting to maintain a bijection between long names and short names. http://www.open.ac.uk/mathtran In other words, I wanted to have two dictionaries f and g such that f[a]

Re: Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread Jonathan Fine
Nick Vatamaniuc wrote: If you need to get a short name, given a long name or vice-verse _and_ the set of short names and long names is distinct (it would be confusing if it wasn't!) then you can just have one dictionary, no need to complicate things too much: f[a]=b f[b]=a You won't know

Re: Two mappings inverse to each other: f, g = biject()

2007-02-06 Thread bearophileHUGS
Jonathan Fine: A google search for biject.py and bijection.py produced no hits, so I suspect that this may not have been done before. There are few (good too) implementations around, but they are called bidict or bidirectional dicts. Sometimes I use this implementation, with few changes: