Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:p 40': 0.04; 'subject:Python': 0.05; 'bytes.': 0.07; 'forcing': 0.07; 'python': 0.08; 'be:': 0.09; 'received:209.85.210.174': 0.13; 'received :mail-iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'py3': 0.16; 'wrote:': 0.18; '2.x': 0.18; 'bytes': 0.18; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'default,': 0.23; 'sat,': 0.25; 'message- id:@mail.gmail.com': 0.28; 'explicit': 0.29; 'unicode': 0.29; 'print': 0.29; 'second': 0.29; 'pm,': 0.29; 'skip:p 30': 0.29; 'lines': 0.30; '3.x': 0.30; 'strings.': 0.30; 'to:addr:python- list': 0.34; 'two': 0.37; 'received:google.com': 0.37; 'steven': 0.38; 'received:209.85': 0.38; 'getting': 0.38; 'relatively': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'difference': 0.40; '2011': 0.61; 'differences,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=HoZRw6dSwkf2oRs2UURiry4q7ZEFc19aNVYL+5HL3f4=; b=M0Z0Tl+Eav2RLTlG56s9wS1JxY1niomhyPoXCNGqb+cRXr1F656aDuMiN6mc0544gD QRXr5e2K1rtEoFGDioVAgnUR5uu2AZEy8/SK0pG+L7+cBNvtGEe/FMefdtJaNS+2i54a hZNTVkbObBzVo+WKQigjsTln4Oe0wDe0+/Dlw= MIME-Version: 1.0 In-Reply-To: <4ed9f416$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ed9f416$0$29988$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 3 Dec 2011 21:44:22 +1100 Subject: Re: Python 2 or 3 From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322909064 news.xs4all.nl 6951 [2001:888:2000:d::a6]:54622 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16589 On Sat, Dec 3, 2011 at 9:04 PM, Steven D'Aprano wrote: > If you can deal with the difference between these two lines without > getting confused: > > print md5.md5("spam").hexdigest() =A0# Python 2.x > print(hashlib.md5("spam").hexdigest()) =A0# Python 3.x The second line needs to be: print(hashlib.md5("spam".encode()).hexdigest()) Relatively insignificant differences, since Python 2 and Python 3 both support both bytes and unicode strings. The only difference is that Py3 makes Unicode the default, forcing you to be explicit when you want bytes. ChrisA