Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explicitly': 0.05; 'subject:Python': 0.06; 'operand': 0.09; 'rewrite': 0.09; 'separately': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'skip:/ 70': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'have:': 0.19; 'slightly': 0.19; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "skip:' 10": 0.31; 'pipe': 0.31; 'produces': 0.31; 'there.': 0.32; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'in:': 0.36; 'should': 0.36; 'pm,': 0.38; 'how': 0.40; 'different': 0.65; '2015': 0.84; 'dict,': 0.84; 'type(s)': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fhQk22O2qN5A5cktKCjQzjQbyjtQUuQYORieXl8yUHg=; b=Mbxt2/jW7kjGGCMkYOkvwLBwSRbsWcDZYAzTrD+GYCmqfATzQlsZTHjnYWhu+P+vZp pS6rUGuueozBt0RC4dINaUpB2gE7l04zl8iCz03pmI6+4KaMH4Kjhs/vkuWFew9kBvjJ aE5hpCmROw7zJ216wTtLKbr5vgl5nnwPA+tQmvnUtokMopBK+ewfS5Lz5pwihyW56jEX IniqYG96zQLj2ft8ddqoux4CVxPEET37Od3ilF50vMUuaKWFFhZPhimZ4lmt0maU0wZ0 +vl4xf8GhqBS6WfS9QfQ/A+IOp2q0yOwuRAiKdLNgE8i/x0oTxTXABMv0M4YleAxM7w7 VLog== MIME-Version: 1.0 X-Received: by 10.107.16.32 with SMTP id y32mr10735666ioi.53.1430468009966; Fri, 01 May 2015 01:13:29 -0700 (PDT) In-Reply-To: <87egn0rcc1.fsf@Equus.decebal.nl> References: <87egn0rcc1.fsf@Equus.decebal.nl> Date: Fri, 1 May 2015 18:13:29 +1000 Subject: Re: Rewriting to Python 3 From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430468012 news.xs4all.nl 2863 [2001:888:2000:d::a6]:53830 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89713 On Fri, May 1, 2015 at 5:22 PM, Cecil Westerhof wrote: > On my system I have: > PARSER_RE_STR = '/(%s)=' % '|'.join(DN_LUT.keys() + DN_LUT.values()) > in: > /usr/lib/python3.4/site-packages/ndg/httpsclient/ssl_peer_verification.py > > In Python 3 that gives: > TypeError: unsupported operand type(s) for +: 'dict_keys' and 'dict_values' > > How should I rewrite this? The keys() and values() methods used to return lists, now they return views. If you explicitly listify them, it should work; alternatively, pipe-join each one separately and then pipe-join the result: PARSER_RE_STR = '/(%s|%s)=' % ('|'.join(DN_LUT.keys()), '|'.join(DN_LUT.values())) Note that this is slightly different from the above; in the case of an empty dict, the original produces empty parentheses, but my alternative will place a junk pipe in there. ChrisA