Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29604
| Date | 2012-09-20 18:58 -0400 |
|---|---|
| Subject | Functional way to compare things inside a list |
| From | thorsopia@lavabit.com |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.990.1348213606.27098.python-list@python.org> (permalink) |
Hi,
list = [{'1': []}, {'2': []}, {'3': ['4', '5']}]
I want to check for a value (e.g. '4'), and get the key of the dictionary
that contains that value.
(Yep, this is bizarre.)
some_magic(list, '4')
=> '3'
What's the functional way to do it?
Is it possible to do it with a one-liner?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Functional way to compare things inside a list thorsopia@lavabit.com - 2012-09-20 18:58 -0400
Re: Functional way to compare things inside a list "Ivan@work" <ivan.cvetkovic@pakel.hr> - 2012-09-21 10:24 +0200
Re: Functional way to compare things inside a list Alexander Blinne <news@blinne.net> - 2012-09-21 10:31 +0200
Re: Functional way to compare things inside a list Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-09-21 10:52 +0200
Re: Functional way to compare things inside a list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 12:54 -0700
Re: Functional way to compare things inside a list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-21 14:49 -0600
Re: Functional way to compare things inside a list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 14:45 -0700
Re: Functional way to compare things inside a list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 14:45 -0700
Re: Functional way to compare things inside a list Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-22 01:25 +0000
Re: Functional way to compare things inside a list Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-22 00:22 -0600
Re: Functional way to compare things inside a list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 23:50 -0700
Re: Functional way to compare things inside a list 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-21 23:50 -0700
Re: Functional way to compare things inside a list Jamie Paul Griffin <jamie@kode5.net> - 2012-09-22 08:08 +0100
Re: Functional way to compare things inside a list Andrew Berg <bahamutzero8825@gmail.com> - 2012-09-22 02:19 -0500
Re: Functional way to compare things inside a list Ramchandra Apte <maniandram01@gmail.com> - 2012-09-22 21:09 -0700
Re: Functional way to compare things inside a list Ramchandra Apte <maniandram01@gmail.com> - 2012-09-22 21:09 -0700
csiph-web