Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #16589
| References | <O3hCq.1112$Ci1.79@uutiset.elisa.fi> <4ed9f416$0$29988$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2011-12-03 21:44 +1100 |
| Subject | Re: Python 2 or 3 |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3249.1322909064.27778.python-list@python.org> (permalink) |
On Sat, Dec 3, 2011 at 9:04 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> If you can deal with the difference between these two lines without
> getting confused:
>
> print md5.md5("spam").hexdigest() # Python 2.x
> print(hashlib.md5("spam").hexdigest()) # 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python 2 or 3 Antti J Ylikoski <antti.ylikoski@tkk.fi> - 2011-12-03 05:54 +0200
Re: Python 2 or 3 Gnarlodious <gnarlodious@gmail.com> - 2011-12-02 20:10 -0800
Re: Python 2 or 3 Andrew Berg <bahamutzero8825@gmail.com> - 2011-12-02 22:20 -0600
Re: Python 2 or 3 Roy Smith <roy@panix.com> - 2011-12-02 23:27 -0500
Re: Python 2 or 3 Dan Stromberg <drsalists@gmail.com> - 2011-12-02 20:42 -0800
Re: Python 2 or 3 Terry Reedy <tjreedy@udel.edu> - 2011-12-03 01:23 -0500
Re: Python 2 or 3 Andrew Berg <bahamutzero8825@gmail.com> - 2011-12-03 00:37 -0600
Re: Python 2 or 3 Andrew Berg <bahamutzero8825@gmail.com> - 2011-12-03 00:41 -0600
Re: Python 2 or 3 jmfauth <wxjmfauth@gmail.com> - 2011-12-03 00:59 -0800
Re: Python 2 or 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-03 10:04 +0000
Re: Python 2 or 3 Chris Angelico <rosuav@gmail.com> - 2011-12-03 21:44 +1100
Re: Python 2 or 3 Arnaud Delobelle <arnodel@gmail.com> - 2011-12-03 12:03 +0000
Re: Python 2 or 3 Gelonida N <gelonida@gmail.com> - 2011-12-03 21:59 +0100
Re: Python 2 or 3 Chris Angelico <rosuav@gmail.com> - 2011-12-04 13:52 +1100
Re: Python 2 or 3 Terry Reedy <tjreedy@udel.edu> - 2011-12-03 21:52 -0500
Re: Python 2 or 3 Chris Angelico <rosuav@gmail.com> - 2011-12-04 14:02 +1100
Re: Python 2 or 3 Zaphod <zaphod@beeblebrox.net> - 2011-12-04 20:18 +0000
Re: Python 2 or 3 Tobiah <tobiah@teranews.com> - 2011-12-06 09:33 -0800
Re: Python 2 or 3 Enrico 'Henryx' Bianchi <henryx_b@yahoo.it> - 2011-12-10 00:16 +0100
Re: Python 2 or 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-10 00:19 +0000
Re: Python 2 or 3 Enrico 'Henryx' Bianchi <henryx_b@yahoo.it> - 2011-12-10 12:49 +0100
csiph-web