Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45707 > unrolled thread

Case insensitive dict

Started by"Joseph L. Casale" <jcasale@activenetwerx.com>
First post2013-05-22 03:59 +0000
Last post2013-05-22 05:19 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Case insensitive dict "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-05-22 03:59 +0000
    Re: Case insensitive dict Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 05:19 +0000

#45707 — Case insensitive dict

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2013-05-22 03:59 +0000
SubjectCase insensitive dict
Message-ID<mailman.1952.1369195266.3114.python-list@python.org>
I was doing some work with the ldap module and required a ci dict that was case
insensitive but case preserving. It turned out the cidict class they implemented was
broken with respect to pop, it is inherited and not re implemented to work. Before
I set about re-inventing the wheel, anyone know of a working implementation?

I noticed twisted has one but it seems to omit pop.

Thanks!
jlc

[toc] | [next] | [standalone]


#45708

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-05-22 05:19 +0000
Message-ID<519c5578$0$1591$c3e8da3$76491128@news.astraweb.com>
In reply to#45707
On Wed, 22 May 2013 03:59:55 +0000, Joseph L. Casale wrote:

> I was doing some work with the ldap module and required a ci dict that
> was case insensitive but case preserving. It turned out the cidict class
> they implemented was broken with respect to pop, it is inherited and not
> re implemented to work. Before I set about re-inventing the wheel,
> anyone know of a working implementation?

class my_cidict(ldap.cidict):
    """Fix problems with pop."""
    def pop(self):
        # insert code here


You don't have to re-invent the entire wheel just to fix one broken 
spoke :-)

Other than that, no, I don't know of any case-insensitive but preserving 
dicts. If you do decide to write one from scratch, please consider 
releasing it as Open Source (I recommend GPL or MIT licences), either as 
a module on PyPI or as a recipe on ActiveState.

https://pypi.python.org/pypi
http://code.activestate.com/recipes/langs/python/



Thank you.






-- 
Steven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web