Call Us Now!
+91 9884412301 | +91 9600112302
info@credosystemz.com
Credo SystemzCredo Systemz
  • Courses
    • TRENDING TECHNOLOGIES TRAINING
    • RPA TRAINING
    • CLOUD COMPUTING TRAINING
    • BIG DATA TRAINING
    • WEB DEVELOPMENT TRAINING
    • MOBILE APPLICATION TRAINING
    • SOFTWARE TESTING TRAINING
    • MICROSOFT TECHNOLOGIES TRAINING
    • JAVA TRAINING
    • PROJECT MANAGEMENT TRAINING
    • DATA WAREHOUSING TRAINING
    • ORACLE TRAINING
    • DATABASE DEVELOPER TRAINING
    • OTHER TRAININGS
    • TRENDING TECHNOLOGIES
      Python Training Data Science Training Angular Training React JS Training ORACLE PRIMAVERA TRAINING Machine Learning Training Hadoop Training Amazon Web Services Training DevOps Training Azure Training PySpark Training MEAN Stack Training
    • RPA TRAINING
      Blue Prism Training UiPath Training Automation Anywhere
    • CLOUD COMPUTING
      Amazon Web Services Training AWS with Devops Training Azure Training AZ 104 Azure Administrator AZ 204 Azure Developer AZ 300 Azure Architect AZ 303 Azure Architect AZ 400 Azure Devops Google Cloud Platform Salesforce Training OpenNebula Training OpenStack Training OpenSpan Training
    • BIG DATA TRAINING
      Hadoop Training Big Data Analytics Training Spark Training
    • WEB DEVELOPMENT
      Angular Training Node JS Training React JS Training React Native Training Ionic Framework Training MEAN Stack Training PHP Training JavaScript Training CoffeeScript Training Less JS Training Graphics Design Training HTML Training CSS Training
    • MOBILE APPLICATION
      Android Training iOS Training iOS Swift Training Kotlin Training Flutter Dart Training
    • SOFTWARE TESTING
      Manual Testing Training UFT / QTP Training Selenium Training API Testing Training Selenium with Python Training Perfecto Mobile Testing Training ETL Testing Training JMeter Training LoadRunner Training Performance Engineering Big Data Testing Training Protractor Testing Training
    • MICROSOFT TECHNOLOGIES
      Dot Net Training MVC Framework ASP.NET MVC with Angular SharePoint Training Advanced Excel Training Excel Macro Training Azure Training Azure Infrastructure Solutions AZ 300 Azure Architect
    • JAVA TRAINING
      Core Java Training Java 8 Training Java J2EE Training Advanced Java Training Hibernate Training Spring Training Struts Training
    • PROJECT MANAGEMENT
      Oracle Primavera Training Primavera P6 Online Training Microsoft Project Training PMP Training ITIL Training Prince2 Training Scrum Master Training Business Analytics Training
    • DATA WAREHOUSING
      Tableau Training Power BI Training Qlikview Training Qlik Sense Training Informatica Training Microstrategy Training Teradata Training Cognos Training SAS Training
    • ORACLE TRAINING
      Oracle PL/SQL Training Oracle DBA Training Oracle Apps Technical Training Oracle Apps SCM Training Oracle Apps HRMS Training Oracle Apps Finance Training Oracle RAC Training PeopleSoft HCM Training PeopleSoft Finance Training
    • DATABASE DEVELOPER
      MongoDB Training Apache Cassandra Training Sybase Training Informix Training Performance Tuning Training
    • OTHER TRAININGS
      Ethical Hacking Training C C++ Training Unix Shell Scripting Training Tensorflow Training Data Modeling Training Workday Training PEGA Training Digital Marketing Training CCNA Training Arduino Training Elm Training Go Programming Training Rust Programming Training CYBER SECURITY TRAINING BIZTALK SERVER TRAINING Spoken English Course
  • Fresher Courses
    • ANGULAR TRAINING
    • REACT TRAINING
    • PYTHON TRAINING
    • JAVA TRAINING
    • SELENIUM TRAINING
  • Placements
    • Career Guidance
      • Interview Questions
      • Resume Building
      • Job Opportunities
    • OVERALL PLACEMENTS
  • About Us
    • Online Training
    • Corporate Training
    • Events
    • Reviews
      • Video Reviews
    • Become an instructor
  • Training
    • Trending Technologies Training
    • RPA TRAINING in Chennai
    • Cloud Computing Training
    • Big Data Hadoop Training in Chennai
    • Web Development Training
    • Mobile Application Training
    • Software Testing Training
    • Microsoft Technologies Training
    • Java Training
    • Project Management Training
    • Data Warehousing Training
    • Oracle Training
    • Database Developer Training
    • Other Training
  • Blogs
    • GENERAL
      • TOP SKILL TO GET A JOB IN MNC
      • INTERVIEW TIPS FOR FRESHERS AND EXPERIENCE
      • TOP TRENDING TECHNOLOGIES
    • DATA SCIENCE
      • MACHINE LEARNING VS DATA SCIENCE
      • DATA SCIENCE INTERVIEW QUESTION AND ANSWER
    • PYTHON
      • WHY LEARN PYTHON
      • JAVA VS PYTHON
      • WHAT IS PYTHON
    • PRIMAVERA
      • LIFECYCLE OF PRIMAVERA
      • EPPM VS PPM
      • PROJECT MANAGEMENT STEPS
    • PMP
      • PMP CERTIFICATION
    • AWS
      • TOP 5 AWS SERVICES
      • AWS VS OPENSTACK
      • AMAZON VS AZURE VS GOOGLE CLOUD
      • WHY DEVELOPERS SHOULD LEARN AWS
    • ANGULAR
      • ANGULAR INTERVIEW QUESTIONS
      • ANGULAR VS REACT VS VUE
    • REACT
      • TOP REASON TO LEARN REACT
    • BLUE PRISM
      • BLUE PRISM VS UI PATH
      • WHAT IS RPA
    • UI PATH
      • RPA CERTIFICATION
    • CLOUD COMPUTING
      • BEST CLOUD COMPUTING SERVICES
    • DEVOPS
      • DEVOPS OVERVIEW
    • NODE JS
      • NODE JS CERTIFICATION
    • HADOOP
      • HADOOP CERTIFICATION
    • AZURE
      • AZURE CERTIFICATION
    • SOFTWARE TESTING
      • HOW TO BECOME A SOFTWARE TESTER
      • MOVE FROM MANUAL TO AUTOMATION TESTING
      • HOW MUCH IS JAVA REQUIRED FOR SELENIUM TESTING
  • Contact Us
  • Courses
    • TRENDING TECHNOLOGIES TRAINING
    • RPA TRAINING
    • CLOUD COMPUTING TRAINING
    • BIG DATA TRAINING
    • WEB DEVELOPMENT TRAINING
    • MOBILE APPLICATION TRAINING
    • SOFTWARE TESTING TRAINING
    • MICROSOFT TECHNOLOGIES TRAINING
    • JAVA TRAINING
    • PROJECT MANAGEMENT TRAINING
    • DATA WAREHOUSING TRAINING
    • ORACLE TRAINING
    • DATABASE DEVELOPER TRAINING
    • OTHER TRAININGS
    • TRENDING TECHNOLOGIES
      Python Training Data Science Training Angular Training React JS Training ORACLE PRIMAVERA TRAINING Machine Learning Training Hadoop Training Amazon Web Services Training DevOps Training Azure Training PySpark Training MEAN Stack Training
    • RPA TRAINING
      Blue Prism Training UiPath Training Automation Anywhere
    • CLOUD COMPUTING
      Amazon Web Services Training AWS with Devops Training Azure Training AZ 104 Azure Administrator AZ 204 Azure Developer AZ 300 Azure Architect AZ 303 Azure Architect AZ 400 Azure Devops Google Cloud Platform Salesforce Training OpenNebula Training OpenStack Training OpenSpan Training
    • BIG DATA TRAINING
      Hadoop Training Big Data Analytics Training Spark Training
    • WEB DEVELOPMENT
      Angular Training Node JS Training React JS Training React Native Training Ionic Framework Training MEAN Stack Training PHP Training JavaScript Training CoffeeScript Training Less JS Training Graphics Design Training HTML Training CSS Training
    • MOBILE APPLICATION
      Android Training iOS Training iOS Swift Training Kotlin Training Flutter Dart Training
    • SOFTWARE TESTING
      Manual Testing Training UFT / QTP Training Selenium Training API Testing Training Selenium with Python Training Perfecto Mobile Testing Training ETL Testing Training JMeter Training LoadRunner Training Performance Engineering Big Data Testing Training Protractor Testing Training
    • MICROSOFT TECHNOLOGIES
      Dot Net Training MVC Framework ASP.NET MVC with Angular SharePoint Training Advanced Excel Training Excel Macro Training Azure Training Azure Infrastructure Solutions AZ 300 Azure Architect
    • JAVA TRAINING
      Core Java Training Java 8 Training Java J2EE Training Advanced Java Training Hibernate Training Spring Training Struts Training
    • PROJECT MANAGEMENT
      Oracle Primavera Training Primavera P6 Online Training Microsoft Project Training PMP Training ITIL Training Prince2 Training Scrum Master Training Business Analytics Training
    • DATA WAREHOUSING
      Tableau Training Power BI Training Qlikview Training Qlik Sense Training Informatica Training Microstrategy Training Teradata Training Cognos Training SAS Training
    • ORACLE TRAINING
      Oracle PL/SQL Training Oracle DBA Training Oracle Apps Technical Training Oracle Apps SCM Training Oracle Apps HRMS Training Oracle Apps Finance Training Oracle RAC Training PeopleSoft HCM Training PeopleSoft Finance Training
    • DATABASE DEVELOPER
      MongoDB Training Apache Cassandra Training Sybase Training Informix Training Performance Tuning Training
    • OTHER TRAININGS
      Ethical Hacking Training C C++ Training Unix Shell Scripting Training Tensorflow Training Data Modeling Training Workday Training PEGA Training Digital Marketing Training CCNA Training Arduino Training Elm Training Go Programming Training Rust Programming Training CYBER SECURITY TRAINING BIZTALK SERVER TRAINING Spoken English Course
  • Fresher Courses
    • ANGULAR TRAINING
    • REACT TRAINING
    • PYTHON TRAINING
    • JAVA TRAINING
    • SELENIUM TRAINING
  • Placements
    • Career Guidance
      • Interview Questions
      • Resume Building
      • Job Opportunities
    • OVERALL PLACEMENTS
  • About Us
    • Online Training
    • Corporate Training
    • Events
    • Reviews
      • Video Reviews
    • Become an instructor
  • Training
    • Trending Technologies Training
    • RPA TRAINING in Chennai
    • Cloud Computing Training
    • Big Data Hadoop Training in Chennai
    • Web Development Training
    • Mobile Application Training
    • Software Testing Training
    • Microsoft Technologies Training
    • Java Training
    • Project Management Training
    • Data Warehousing Training
    • Oracle Training
    • Database Developer Training
    • Other Training
  • Blogs
    • GENERAL
      • TOP SKILL TO GET A JOB IN MNC
      • INTERVIEW TIPS FOR FRESHERS AND EXPERIENCE
      • TOP TRENDING TECHNOLOGIES
    • DATA SCIENCE
      • MACHINE LEARNING VS DATA SCIENCE
      • DATA SCIENCE INTERVIEW QUESTION AND ANSWER
    • PYTHON
      • WHY LEARN PYTHON
      • JAVA VS PYTHON
      • WHAT IS PYTHON
    • PRIMAVERA
      • LIFECYCLE OF PRIMAVERA
      • EPPM VS PPM
      • PROJECT MANAGEMENT STEPS
    • PMP
      • PMP CERTIFICATION
    • AWS
      • TOP 5 AWS SERVICES
      • AWS VS OPENSTACK
      • AMAZON VS AZURE VS GOOGLE CLOUD
      • WHY DEVELOPERS SHOULD LEARN AWS
    • ANGULAR
      • ANGULAR INTERVIEW QUESTIONS
      • ANGULAR VS REACT VS VUE
    • REACT
      • TOP REASON TO LEARN REACT
    • BLUE PRISM
      • BLUE PRISM VS UI PATH
      • WHAT IS RPA
    • UI PATH
      • RPA CERTIFICATION
    • CLOUD COMPUTING
      • BEST CLOUD COMPUTING SERVICES
    • DEVOPS
      • DEVOPS OVERVIEW
    • NODE JS
      • NODE JS CERTIFICATION
    • HADOOP
      • HADOOP CERTIFICATION
    • AZURE
      • AZURE CERTIFICATION
    • SOFTWARE TESTING
      • HOW TO BECOME A SOFTWARE TESTER
      • MOVE FROM MANUAL TO AUTOMATION TESTING
      • HOW MUCH IS JAVA REQUIRED FOR SELENIUM TESTING
  • Contact Us

Main Differences Python 2 vs Python 3

  • Home
  • Main Differences Python 2 vs Python 3

Python Version History


Let’s have a detailed understanding about Python 2 vs Python 3 release dates
S. NoPython 2 Version & Release DatePython 3 Version & Release Date
1Python 2.0 - released on October 16, 2000Python 3.0 - released on December 3, 2008
2Python 2.1 - released on April 17, 2001Python 3.1 - released on June 27, 2009
3Python 2.2 - released on December 21, 2001Python 3.2 - released on February 20, 2011
4Python 2.3 - released on July 29, 2003Python 3.3 - released on September 29, 2012
5Python 2.4 - released on November 30, 2004Python 3.4 - released on March 16, 2014
6Python 2.5 - released on September 19, 2006Python 3.5 - released on September 13, 2015
7Python 2.6 - released on October 1, 2008Python 3.6 - released on October 2016
8Python 2.7 - released on July 3, 2010Python 3.7 - released on June 2018

Python 2 vs Python 3


S. NoKey ComparisonPython 2Python 3
1Release Date20002008
2SyntaxThe syntax of Python 2 was difficult to understandThe syntax of Python 3 is simpler and easier
3Print Functionprint "hello"print ("hello")
4Integer DivisionWhen two integers are divided, you always get an integer value.Whenever two integers are divided, you always get a float value
5UnicodeTo store Unicode string value, you would require to define them with "u".In Python 3, default storing of strings is Unicode.
6Rules of ordering ComparisonsRules of ordering comparison are very complex.In this version, Rules of ordering comparisons is very easier
7XrangeIn Python 2, the xrange () is used for iterations.The new Range () function introduced to perform iterations.
8Returning iterable objects instead of listsIn Python 2, some function & methods return listsIn Python 3, some function & methods return iterable objects
9Parsing user inputs via input ()raw_input () to be used in order to read other data types than String It always stores the user input as Str objects
10RoundingIn Python 2, decimals are rounded to the nearest number (No matter be it a Odd or Even number)In Python 3, decimals are rounded to the nearest even number.
11Raising ExceptionsPython 2 accepts both notation (Old & New Syntax). Meaning it should be enclosed in notations or parenthesis.It should be enclosed in parenthesis.
12Handling ExceptionsNo need to use any keyword Eg: print 'Python', python_version () try: NameError except NameError, err: print err, '--> our Error message'Need to use "as" keyword to handle the exception Eg: print ('Python', python_version ()) try: NameError except NameErroras err: print (err, '--> Error message')
13Leak of variablesThe value of the global variable will change while using it inside for-loop.The value of variables never changes.
14Backward compatibilityPython version 3 is not backwardly compatible with Python 2.Not difficult to port python 2 to python 3 but it is never reliable.
15LibraryMany older libraries created for Python 2 is not forward-compatible.Many recent developers are creating libraries which you can only use with Python 3.
These are the comparison between python 2 vs python 3.

Why to Choose Python 3

In Python, Version 3 is the future, here are some of the reason why to choose Python 3
  • Legacy Python 2 code will no longer be maintained after 2020
  • Upgrade option is available in Python 3
  • Easier to write a code
  • Avoid the syntax confusion
  • Improved number management helps to perform math calculation
  • Lot of popular add-ons are supported
  • Unicode’s are supported

Porting Process / Migrating Process – From Python 2 to Python 3

Porting / Migrating the code from Python 2 to Python 3 involves only 3 steps. They are
  • Auto Conversion
  • Manual Changes
  • Runtime Validation & Fix

Auto Conversion

  • Python 3 team has provided a new tool called 2to3tool where it reads the Python 2.x source and apply some fixers to convert it in to Python 3.x code where the common syntax change will be done by the auto conversion tool.
  • Library named “lib2to3” contains rich set of fixers which will handle almost all the code.
  • For example, you have a python 2 source file named example.py and if you want to convert it in to python 3 then we can use the library 2to3 in the command line as below $2to3 example.py This will do necessary modifications in the Source file

Manual Changes

  • If you ask Auto Conversion will do complete porting then the answer is “No, it will not do complete porting”.
  • We need to run the Test Class and need to see if there are any errors. If error exists then that needs to be fixed accordingly based on the switching or comparison issue where the key name to be fixed in the function.
  • To be honest, this is an iterative process or approach until all the code runtime has been validated.
  • Once the common pattern has been identified, then there is another process named as “grep” & “sed” to replace across many files.

Runtime Validation & Fix:

  • Once all the conversion process has been done, then we need to perform lot of code runtime validation. This will help us to identify the things earlier which might cause an issue.
  • As python is a dynamic language, it is better to avoid visual static code inspection / changes.

Common Runtime Problems and it’s solution:

Problem 1:
While porting, we may face “Type errors” during Runtime like bytes instead of str and vice versa
Solution 1:
We need to see the variable type in the statement and based on that use, xxx. encode () to get bytes or xxx. decode () to get strings If input is not known, then use try xxx. encode () except Attribute Error: pass
Problem 2:
Type Error: root – ERROR – ——->installation failed: a bytes-like object is required, not ‘str’
Solution 2:
Change the byte type to string type or add b as prefix to the string under comparison
Problem 3:
AttributeErrorsuite_setUp () or suite_tearDown () is missing for some test suites.
Solution 3:
Add the dummy suite_setUp () and suite_tearDown () methods.
Problem 4:
Tab Error: inconsistent use of tabs and spaces in indentation
Solution 4:
Search for tab characters and replace with space characters.
Problem 5:
Type Error: ‘FileNotFoundError’ object is not sub-scriptable
Solution 5:
In Python 3, FileNotFoundError is not sub-scriptable so use errno attribute, e.errno

Steps to be performed post migration:

  • Caniusepython3 will help to check which software dependencies will block you from supporting Python 3 using the tools provided.
  • Futurize or Modernize will make sure that your Python 2 code is compatible with Python 3
  • In setup.py file, one can update the classifiers which contain Programming Language:: Python :: 3 to indicate your code supports Python 2 and 3.
  • Automating tests using tox will help you to understand that code stays compatible with Python 2 and 3.
Related Articles refer here:
Python Programming | Python Trends in 2023 | Why need to learn python ?| Python certification course in chennai
For Knowledge : Python

QUICK ENQUIRY


Customer reviews across the Internet

CREDO SYSTEMZ

5 out of 5 based on 25328 ratings. 25328 user reviews.

Other Training

  • Trending Technologies Training
  • RPA TRAINING in Chennai
  • Cloud Computing Training
  • Web Development Training
  • Big Data Hadoop Training in Chennai
  • Software Testing Training
  • Mobile Application Training
  • Project Management Training
  • Microsoft Technologies Training
  • Java Training
  • Data Warehousing Training
  • Oracle Training
  • Database Developer Training
  • Other Training

INDIA LOCATIONS

New #30,Old #16A,
Rajalakshmi Nagar, Velachery,
Chennai - 600 042.
Mobile: +91 9884412301

Plot No.8, Vinayaga Avenue,
Rajiv Gandhi Salai, Okkiampettai(OMR),
Chennai – 600 097.
Mobile: +91 9600112302

Refund/Cancellation Policy

INTERNATIONAL LOCATIONS

USA
Houchin Drive, Franklin, TN -37064
Tennessee
Email: info@credosystemz.com
Web: www.credosystemz.com
Chat With Us

UAE
Sima Electronic Building,
LLH Opposite,
Electra Street – Abu Dhabi
Email: info@credosystemz.com
Web: www.credosystemz.com
Chat With Us

TRENDING COURSES

  • Python Training in Chennai
  • Data Science Training in Chennai
  • AWS Training in Chennai
  • Big Data Hadoop Training in Chennai
  • Machine Learning Training in Chennai
  • Selenium Training in Chennai
  • Angular Training in Chennai
  • Oracle Primavera P6 Online Training
  • Mean Stack Training in Chennai
  • DevOps Training in Chennai
  • Microsoft Azure Training in Chennai
  • GCP Training in Chennai

Copyright 2022 CREDO SYSTEMZ | All Rights Reserved.