Re: Handling 2.7 and 3.0 Versions of Dict

2011-09-02 Thread Gabriel Genellina
En Wed, 31 Aug 2011 22:28:09 -0300, Travis Parks jehugalea...@gmail.com escribió: On Aug 31, 7:37 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Ian Kelly wrote: if sys.version_info (3,): getDictValues = dict.itervalues else: getDictValues = dict.values (which is

Re: Handling 2.7 and 3.0 Versions of Dict

2011-09-02 Thread Travis Parks
On Sep 2, 12:36 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 31 Aug 2011 22:28:09 -0300, Travis Parks jehugalea...@gmail.com   escribi : On Aug 31, 7:37 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Ian Kelly wrote: if sys.version_info (3,):     getDictValues =

Re: Handling 2.7 and 3.0 Versions of Dict

2011-09-02 Thread Terry Reedy
On 9/2/2011 12:53 PM, Travis Parks wrote: On Sep 2, 12:36 pm, Gabriel Genellinagagsl-...@yahoo.com.ar Those if/else are at global scope. An 'if' statement does not introduce a new scope; so getDictValues, despite being indented, is defined at global scope, and may be used anywhere in the

Re: Handling 2.7 and 3.0 Versions of Dict

2011-09-02 Thread Gabriel Genellina
En Fri, 02 Sep 2011 13:53:37 -0300, Travis Parks jehugalea...@gmail.com escribió: On Sep 2, 12:36 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Wed, 31 Aug 2011 22:28:09 -0300, Travis Parks jehugalea...@gmail.com escribi : On Aug 31, 7:37 pm, Gregory Ewing

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-31 Thread Martin v. Loewis
Am 31.08.2011 03:43, schrieb Travis Parks: I am writing a simple algorithms library that I want to work for both Python 2.7 and 3.x. I am writing some functions like distinct, which work with dictionaries under the hood. The problem I ran into is that I am calling itervalues or values

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-31 Thread Ian Kelly
On Wed, Aug 31, 2011 at 3:55 AM, Martin v. Loewis mar...@v.loewis.de wrote: if sys.version_info (3,): def getDictValues(dict): return dict.itervalues() else: def getDictValues(dict): return dict.values() The extra level of function call indirection is unnecessary here. Better

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-31 Thread Gregory Ewing
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

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-31 Thread Travis Parks
On Aug 31, 7:37 pm, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: 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

Handling 2.7 and 3.0 Versions of Dict

2011-08-30 Thread Travis Parks
I am writing a simple algorithms library that I want to work for both Python 2.7 and 3.x. I am writing some functions like distinct, which work with dictionaries under the hood. The problem I ran into is that I am calling itervalues or values depending on which version of the language I am working

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-30 Thread Terry Reedy
On 8/30/2011 9:43 PM, Travis Parks wrote: I am writing a simple algorithms library that I want to work for both Python 2.7 and 3.x. I am writing some functions like distinct, which work with dictionaries under the hood. The problem I ran into is that I am calling itervalues or values depending