[Tarantool-patches] [PATCH v1 1/4] test: fix app-tap/http_client.test.lua

Alexander Turenko alexander.turenko at tarantool.org
Thu Jan 14 15:57:02 MSK 2021


On Thu, Jan 14, 2021 at 03:52:06PM +0300, Sergey Bronnikov wrote:
> Thanks for review!
> 
> On 14.01.2021 15:23, Alexander Turenko wrote:
> > > @@ -76,7 +76,7 @@ def post_handle(env, response):
> > >       code = "200 OK"
> > >       body = [env["wsgi.input"].read()]
> > >       headers = []
> > > -    for key,value in env.iteritems():
> > > +    for key,value in iter(env.items()):
> > AFAIR, <dict>.items() forms a list on Python 2, but creates an iterator
> > object on Python 3. Both are suitable for the for loop expression and
> > there is no much difference when the dictionary in not large.
> 
> Generally it is so. Although PEP-0469 recommends to convert d.items() to
> iter(d.iteritems()) [1].

It is the most common way: so if one pass the iterator to some function,
which expects an iterator object (but not a list), it'll work.

However for most usages (such as in a loop expressions), .items() is
enough.


More information about the Tarantool-patches mailing list