Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12533
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
| Newsgroups | comp.lang.python |
| Subject | Re: Handling 2.7 and 3.0 Versions of Dict |
| Date | Thu, 01 Sep 2011 11:37:32 +1200 |
| Lines | 31 |
| Message-ID | <9c7utuF8q8U1@mid.individual.net> (permalink) |
| References | <50924476-9ada-487e-bd4b-5b77bce11d5b@gz5g2000vbb.googlegroups.com> <4E5E051B.8060002@v.loewis.de> <mailman.611.1314805519.27778.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net xAHbsWoYy/zz37uU4i7JtQJe6yyG1NV0x0i8Y/M7KEPD5xDlW8 |
| Cancel-Lock | sha1:7cRMjWhdUf3+MhpT6sArQxQLimc= |
| User-Agent | Mozilla Thunderbird 1.0.5 (Macintosh/20050711) |
| X-Accept-Language | en-us, en |
| In-Reply-To | <mailman.611.1314805519.27778.python-list@python.org> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12533 |
Show key headers only | View raw
Ian Kelly wrote:
> if sys.version_info < (3,):
> getDictValues = dict.itervalues
> else:
> getDictValues = dict.values
>
> (which is basically what the OP was doing in the first place).
And which he seemed to think didn't work for some
reason, but it seems fine as far as I can tell:
Python 2.7 (r27:82500, Oct 15 2010, 21:14:33)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> gv = dict.itervalues
>>> d = {1:'a', 2:'b'}
>>> gv(d)
<dictionary-valueiterator object at 0x2aa210>
% python3.1
Python 3.1.2 (r312:79147, Mar 2 2011, 17:43:12)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> gv = dict.values
>>> d = {1:'a', 2:'b'}
>>> gv(d)
dict_values(['a', 'b'])
--
Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Handling 2.7 and 3.0 Versions of Dict Travis Parks <jehugaleahsa@gmail.com> - 2011-08-30 18:43 -0700
Re: Handling 2.7 and 3.0 Versions of Dict Terry Reedy <tjreedy@udel.edu> - 2011-08-30 23:33 -0400
Re: Handling 2.7 and 3.0 Versions of Dict "Martin v. Loewis" <martin@v.loewis.de> - 2011-08-31 11:55 +0200
Re: Handling 2.7 and 3.0 Versions of Dict Ian Kelly <ian.g.kelly@gmail.com> - 2011-08-31 09:44 -0600
Re: Handling 2.7 and 3.0 Versions of Dict Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-09-01 11:37 +1200
Re: Handling 2.7 and 3.0 Versions of Dict Travis Parks <jehugaleahsa@gmail.com> - 2011-08-31 18:28 -0700
Re: Handling 2.7 and 3.0 Versions of Dict "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-09-02 13:36 -0300
Re: Handling 2.7 and 3.0 Versions of Dict Travis Parks <jehugaleahsa@gmail.com> - 2011-09-02 09:53 -0700
Re: Handling 2.7 and 3.0 Versions of Dict Terry Reedy <tjreedy@udel.edu> - 2011-09-02 16:22 -0400
Re: Handling 2.7 and 3.0 Versions of Dict "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-09-02 17:29 -0300
csiph-web