Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #89713

Re: Rewriting to Python 3

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 <rosuav@gmail.com>
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 <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4.1430468012.3347.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Fri, May 1, 2015 at 5:22 PM, Cecil Westerhof <Cecil@decebal.nl> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Rewriting to Python 3 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-01 09:22 +0200
  Re: Rewriting to Python 3 Ben Finney <ben+python@benfinney.id.au> - 2015-05-01 17:56 +1000
  Re: Rewriting to Python 3 Peter Otten <__peter__@web.de> - 2015-05-01 10:09 +0200
  Re: Rewriting to Python 3 Chris Angelico <rosuav@gmail.com> - 2015-05-01 18:13 +1000
  Re: Rewriting to Python 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-01 09:10 +0100
  Re: Rewriting to Python 3 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-01 16:41 +0200
    Re: Rewriting to Python 3 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-01 16:52 +0200

csiph-web