[Python-3000] [Python-Dev] Byte literals (was Re: [Python-checkins] Changing string constants to byte arrays ( r55119 - in python/branches/py3k-struni/Lib: codecs.py test/test_codecs.py ))
Paul Moore
p.f.moore at gmail.com
Thu May 10 10:26:38 CEST 2007
On 09/05/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> Maybe the tool has gotten smart enough to avoid constructions like:
>
> for k, v in list(dict.items()):
>
> for i in list(range(10)):
>
> but I can't help feeling there will always be a few cases where it
> makes the code longer and worse.
Why don't you (in these cases) change your 2.x code to
for k, v in dict.iteritems():
for i in xrange(10):
Then 2to3 will do the right thing, *and* your 2.x code is improved...
> knowing it will run OK in both versions. I will not be happy if I
> have to do this editing more than once.
If you edit the 2.6 source, you only need to do that once.
Paul.
More information about the Python-3000
mailing list