subscripting Python 3 dicts/getting the only value in a Python 3 dict
Marko Rauhamaa
marko at pacujo.net
Tue Jan 12 14:42:41 EST 2016
More information about the Python-list mailing list
Tue Jan 12 14:42:41 EST 2016
- Previous message (by thread): subscripting Python 3 dicts/getting the only value in a Python 3 dict
- Next message (by thread): subscripting Python 3 dicts/getting the only value in a Python 3 dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jussi Piitulainen <jussi.piitulainen at helsinki.fi>: > But the most readable thing might be to have a function that extracts > the sole value by whatever means: > > >>> def sole(d): [o] = d.values() ; return o > ... > >>> sole(shoe) > 3.141592653589793 In the same vein: >>> def sole(d): ... for o in d.values(): ... return o ... >>> sole(shoe) 3.141592653589793 Marko
- Previous message (by thread): subscripting Python 3 dicts/getting the only value in a Python 3 dict
- Next message (by thread): subscripting Python 3 dicts/getting the only value in a Python 3 dict
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list