Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Python 2 or 3 used in "Automate boring stuff using Python"?

 
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what little I know, Python 2 has a significantly larger user base (e.g., number of installations, LOC of legacy code, ...) than Python 3 and the newer Python is incompatible in some ways.

I'd like to know if this difference is significant so far as this book is concerned, and if so, which flavor of Python this book will be using and why. I did not find this information in the Amazon page.

thank you,
- Anand
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took a look in the amazon sample, and it says that the code in the book is using python 3, and might not run correctly, if at all, on python 2.
 
Anand Hariharan
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alaa Nassef wrote:I took a look in the amazon sample, and it says that the code in the book is using python 3, and might not run correctly, if at all, on python 2.



Thanks Alaa. I had taken a look at the Amazon sample prior to my post. I took another look at it again after your post. I was unable to find it first. Then yet another look. And yes, there was indeed a statement ("warning") in the 'Downloading and Installing Python' section in the kindle edition of the book's preview.

sincerely,
- Anand
 
Alaa Nassef
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's it
 
Author
Posts: 31
5
Python
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Automate book uses Python 3. I made the switch to Python 3 years ago.

Python 2 still does have significant sway (estimated at about 85% or so of developers). But this book is for beginners who will be writing small scripts, not developers working on large existing projects. Unless you need to work on existing code where it would be too expensive to migrate, you should be using Python 3. At this point, most of Python's modules have been updated with Python 3 compatibility.

One the main changes for Python 3 was handling unicode text in a way that forces developers to understand unicode issues. With Python 2, the Python interpreter "helpfully" lets you ignore this (but your code will probably crash when it encounters non-ascii characters). I highly recommend Ned Batchelder's talk on Unicode: it is perfect for understanding both Unicode and what changes went into Python 3: Pragmatic Unicode, or, How to Stop the Pain

I think the main reason Python 3 hasn't caught on is that there hasn't yet been enough gotta-have, Python 3 only features to encourage people to switch. Though Python 3 certainly has been making a lot of headway in this direction (check out the "What's New in Python 3.X" documents for 3.0 to 3.5)
 
reply
    Bookmark Topic Watch Topic
  • New Topic