Discussion:
[Tutor] 2 vs 3
Sithembewena Lloyd Dube
2015-09-05 13:06:25 UTC
Permalink
Hi all,

A colleague and I are embarking on a project for a client. We have agreed
to implement a REST API in Falcon (www.falconframework.org) and colleague
wants to implement it in Python 3.

Are there any advantages/ disadvantages of using Python 3? I have always
stuck to Python 2.
--
Kind regards,
Sithu Lloyd Dube
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Steven D'Aprano
2015-09-05 13:25:41 UTC
Permalink
Post by Sithembewena Lloyd Dube
Hi all,
A colleague and I are embarking on a project for a client. We have agreed
to implement a REST API in Falcon (www.falconframework.org) and colleague
wants to implement it in Python 3.
Are there any advantages/ disadvantages of using Python 3? I have always
stuck to Python 2.
Advantages of Python 2:
=======================


- More tutorials and websites about Python 2.

- Slightly faster for some operations.

- Some operations with mixed Unicode text + bytes succeed without
raising an exception; the result isn't what you want, but if you
are the sort of programmer who thinks that it is better to get the
wrong answer with no error instead of an error, you might think
this is an advantage.

- Some libraries are available for Python 2 but not 3 yet.



Advantages of Python 3:
=======================

- All on-going development of the language and new features will go
into Python 3.

- Cleaner, more consistent language: only one type of class, not
two; no longer has the proliferation of similar dictionary
methods (e.g. keys, iterkeys, viewkeys); std lib is organised
a bit better.

- Useful new features that Python 2 does not have, such as Enums,
asyncio, pathlib, and others.

- __del__ finalizer methods are easier and safer now.

- Cleaner separation between Unicode text and bytes. If you accidently
mix them together, you get an exception, instead of Python trying to
guess what result you might want.

- More efficient and cleaner handling of .pyc files.


If you decide to use Python 3, 3.3 should be the oldest version you
consider. 3.4 has many improvements and you should consider using that.
--
Steve
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-09-05 15:37:57 UTC
Permalink
Post by Steven D'Aprano
Post by Sithembewena Lloyd Dube
Hi all,
A colleague and I are embarking on a project for a client. We have agreed
to implement a REST API in Falcon (www.falconframework.org) and colleague
wants to implement it in Python 3.
Are there any advantages/ disadvantages of using Python 3? I have always
stuck to Python 2.
If you decide to use Python 3, 3.3 should be the oldest version you
consider. 3.4 has many improvements and you should consider using that.
People should be aware that Python 3.5 is scheduled for full release on
September 13, 2015, see https://www.python.org/dev/peps/pep-0478/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Sithembewena Lloyd Dube
2015-09-05 19:03:04 UTC
Permalink
@Steven, @Mark,

Thanks for the feedback.
Post by Mark Lawrence
Post by Steven D'Aprano
Post by Sithembewena Lloyd Dube
Hi all,
A colleague and I are embarking on a project for a client. We have agreed
to implement a REST API in Falcon (www.falconframework.org) and colleague
wants to implement it in Python 3.
Are there any advantages/ disadvantages of using Python 3? I have always
stuck to Python 2.
If you decide to use Python 3, 3.3 should be the oldest version you
consider. 3.4 has many improvements and you should consider using that.
People should be aware that Python 3.5 is scheduled for full release on
September 13, 2015, see https://www.python.org/dev/peps/pep-0478/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
--
Kind regards,
Sithu Lloyd Dube
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-09-05 22:33:02 UTC
Permalink
Post by Sithembewena Lloyd Dube
A colleague and I are embarking on a project for a client. We have agreed
to implement a REST API in Falcon (www.falconframework.org) and colleague
wants to implement it in Python 3.
Python 3 is the future and where we will all inevitably
wind up. There are very few people still using Python 1.x
nowadays, progress happens.

And its much easier to start a new project on a new version
that to try to migrate it after your got it built. So I'd
see this as an opportunity to move with the times and go
with v3.

Once you get used to it - and it is a big jump, don't
underestimate the learning time - v3 is superior. It's
more consistent and the new features are potentially
useful. Take the time to really explore what v3 offers,
not just the new syntax items.

Caveat: If you need a specialist library that hasn't been
ported that may force you to use v2. But very few of the
s significant libraries are stuck on 2 now.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Grady Martin
2015-09-07 01:15:52 UTC
Permalink
Post by Alan Gauld
Once you get used to it - and it is a big jump, don't
underestimate the learning time - v3 is superior.
This is the first I've heard someone describe the learning curve from 2 to 3 in anything but negligible terms. What makes the jump big?
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailma
Laura Creighton
2015-09-07 09:14:10 UTC
Permalink
Post by Grady Martin
Post by Alan Gauld
Once you get used to it - and it is a big jump, don't
underestimate the learning time - v3 is superior.
This is the first I've heard someone describe the learning curve from 2 to 3 in anything but negligible terms. What makes the jump big?
It's big for people in English speaking languges who have never used
unicode before. Those of us who have been using unicode with Python 2
for a very long time, in contrast, say 'my word, this is a whole lot
simpler'. :)

Laura
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://ma
Alan Gauld
2015-09-07 09:16:16 UTC
Permalink
Post by Grady Martin
Post by Alan Gauld
Once you get used to it - and it is a big jump, don't
underestimate the learning time - v3 is superior.
This is the first I've heard someone describe the learning curve from 2
to 3 in anything but negligible terms. What makes the jump big?
Yes, that's what I thought too. Then I tried it.
It's nothing huge, but thee are a lot of small changes
that continually catch you out.

Modules have been moved into packages
Module names have changed.
Functions have been moved to new modules.
Function return types have changes
Exception handling has changed
Error types have changed
Class heirarchies have changed (especially the io hierarchy)
Data types have changed
metaclasses have changed
Strings have changed to Unicode and bytes

And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.

I found it took me a couple of months before I stopped
having to jump into the docs and use help() even where I
thought I knew what I was doing.

Don't get me wrong, its still a worthwhile thing to do.
But don't be fooled by the hype, it is not a trivial change.
Your coding speed will slow down for a while till you
get used to it.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mail
Laura Creighton
2015-09-07 09:32:32 UTC
Permalink
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.

Laura

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-09-07 10:01:00 UTC
Permalink
Post by Laura Creighton
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.
No 'big push' because there's too much historic code out there.
But I thought I'd read somewhere when it first came out that
the old style was deprecated? But I may be hallucinating! :-)

OTOH the new style brings enough benefits, especially in the
areas of dynamic formatting, that I'd strongly suggest moving
to it if you are making the jump to v3 anyway!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Steven D'Aprano
2015-09-07 11:58:27 UTC
Permalink
Post by Alan Gauld
Post by Laura Creighton
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.
No 'big push' because there's too much historic code out there.
But I thought I'd read somewhere when it first came out that
the old style was deprecated? But I may be hallucinating! :-)
When the format() method first came out, there was talk about
deprecating % formatting, but it was only talk and never became
official.
Post by Alan Gauld
OTOH the new style brings enough benefits, especially in the
areas of dynamic formatting, that I'd strongly suggest moving
to it if you are making the jump to v3 anyway!
It's worth learning both formatting systems, even if you're just using
Python 2. The format method started in 2.6, and 2.7 added the
"autonumbering" feature that makes it much easier to use:

"{0} {1} {2}".format(a, b, c) # needed in 2.6
"{} {} {}".format(a, b, c) # 2.7 and up


Having said that, I still don't know how to use format other than the
basics, as most of the code I write has to be compatible with 2.4
onwards.
--
Steve
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Sithembewena Lloyd Dube
2015-09-07 14:28:15 UTC
Permalink
This has turned into a very interesting discussion. Thank you to everyone
who's participating and sharing nuggets of information on 2 vs 3.
Post by Steven D'Aprano
Post by Alan Gauld
Post by Laura Creighton
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.
No 'big push' because there's too much historic code out there.
But I thought I'd read somewhere when it first came out that
the old style was deprecated? But I may be hallucinating! :-)
When the format() method first came out, there was talk about
deprecating % formatting, but it was only talk and never became
official.
Post by Alan Gauld
OTOH the new style brings enough benefits, especially in the
areas of dynamic formatting, that I'd strongly suggest moving
to it if you are making the jump to v3 anyway!
It's worth learning both formatting systems, even if you're just using
Python 2. The format method started in 2.6, and 2.7 added the
"{0} {1} {2}".format(a, b, c) # needed in 2.6
"{} {} {}".format(a, b, c) # 2.7 and up
Having said that, I still don't know how to use format other than the
basics, as most of the code I write has to be compatible with 2.4
onwards.
--
Steve
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
--
Kind regards,
Sithu Lloyd Dube
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Steven D'Aprano
2015-09-07 11:34:52 UTC
Permalink
Post by Laura Creighton
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.
If you're referring to "%s" % x versus "{}".format(x), no, there's no
official push for format. They tried that, but the push-back from people
who like the %s formatting was too large.

%s formatting is NOT deprecated, and will not be any time in the
forseeable future;

%s formatting is still necessary for anyone who wants to write code that
works with version 2.4 on up;

format() is more powerful, but also slower.

Of course individual projects and work-places may include their own
in-house rules, which may prefer %s or format. But as far as Python the
language goes, you can use whichever you prefer.
--
Steve
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-09-07 16:58:53 UTC
Permalink
Post by Steven D'Aprano
Post by Laura Creighton
Post by Alan Gauld
And of course if you are really moving to the v3 way of
doing things you should move to using the new string
formatting style.
I don't think there is any great push to prefer the new style over
the old style 'just because' when you are doing simple things.
If you're referring to "%s" % x versus "{}".format(x), no, there's no
official push for format. They tried that, but the push-back from people
who like the %s formatting was too large.
%s formatting is NOT deprecated, and will not be any time in the
forseeable future;
http://www.gossamer-threads.com/lists/python/dev/969817
http://bugs.python.org/issue14123
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Continue reading on narkive:
Loading...