Comments
yourfanat wrote: I am using another tool for Oracle developers - dbForge Studio for Oracle. This IDE has lots of usefull features, among them: oracle designer, code competion and formatter, query builder, debugger, profiler, erxport/import, reports and many others. The latest version supports Oracle 12C. More information here.
Cloud Expo on Google News
SYS-CON.TV

2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
Python 2 and Python 3 | @DevOpsSummit #DevOps #Python #Microservices
The transition from Python 2 to Python 3 is happening slowly, but it is underway

The Key Differences Between Python 2 and Python 3

If you are new to Python, you might be confused about the different versions that are available. Although Python 3 is the latest generation of the language, many programmers still use Python 2.7, the final update to Python 2, which was released in 2010.

There is currently no clear-cut answer to the question of which version of Python you should use; the decision depends on what you want to achieve. While Python 3 is clearly the future of the language, some programmers choose to remain with Python 2.7 because some older libraries and packages only work in Python 2.

Why Are There Different Versions of Python?

Programming languages constantly evolve as developers extend the functionality of the language and iron out quirks that cause problems for developers. Python 3 was introduced in 2008 with the aim of making Python easier to use and change the way it handles strings to match the demands placed on the language today. Programmers who first learned to program in Python 2 sometimes find the new changes difficult to adjust to, but newcomers often find that the new version of the language makes more sense.

Python 3.0 is fundamentally different to previous Python releases because it is the first Python release that is not compatible with older versions. Programmers usually don’t need to worry about minor updates (e.g. from 2.6 to 2.7) as they usually only change the internal workings of Python and don’t require programmers to change their syntax. The change between Python 2.7 (the final version of Python 2) and Python 3.0 is much more significant — code that worked in Python 2.7 may need to be written in a different way to work in Python 3.0.

Key Differences Between Python 2 and Python 3

Here are some key differences between Python 2 and Python 3 that can make the new version of the language less confusing for new programmers to learn:

  • Print: In Python 2, “print” is treated as a statement rather than a function. There is no need to wrap the text you want to print in parentheses, although you can if you want. This can be confusing, as most other actions in Python use functions that require the arguments to be placed inside parentheses. It can also lead to unexpected outcomes if you put parentheses around a comma-separated list of items that you want to print. In contrast, Python 3 explicitly treats “print” as a function, which means you have to pass the items you need to print to the function in parentheses in the standard way, or you will get a syntax error. Some Python 2 programmers find this change annoying, but it can help to prevent mistakes.

  • Integer Division: Python 2 treats numbers that you type without any digits after the decimal point as integers, which can lead to some unexpected results during division. For example, if you type the expression 3 / 2 in Python 2 code, the result of the evaluation will be 1, not 1.5 as you might expect. This is because Python 2 assumes that you want the result of your division to be an integer, so it rounds the calculation down to the nearest whole number. In order to get the result 1.5, you would have to write 3.0 / 2.0 to tell Python that you want it to return a float, that is, to include digits after the decimal point in the result. Python 3 evaluates 3 / 2 as 1.5 by default, which is more intuitive for new programmers.

  • “For Loop” Variables: In previous versions of Python, giving the variable that is iterated over in a “for loop” the same name as a global variable could lead to the value of the global variable being changed — something you usually don’t want. This irritating bug has been fixed in Python 3, so you can use a variable name you already used for the control variable in your “for loop” without worrying about it leaking out and messing with the values of the variables in the rest of your code.

  • Unicode Strings: Python 3 stores strings as Unicode by default, whereas Python 2 requires you to mark a string with a “u” if you want to store it as Unicode. Unicode strings are more versatile than ASCII strings, which are the Python 2 default, as they can store letters from foreign languages as well as emoji and the standard Roman letters and numerals. You can still label your Unicode strings with a “u” if you want to make sure your Python 3 code is compatible with Python 2.

  • Raising Exceptions: Python 3 requires different syntax for raising exceptions. If you want to output an error message to the user, you need to use the syntax:

raise IOError(“your error message”)

This syntax works in Python 2 as well. The following code works only in Python 2, not Python 3:

raise IOError, “your error message”

There are many other examples of slight differences in syntax between Python 2 and Python 3. A cheat sheet of key syntax differences is available from Python-Future to help you write code that is compatible with both versions of Python. In addition to syntax differences, there are other key differences, such as how the two versions of Python handle strings, as described above. Python 3.3 performs at approximately the same speed as Python 2.7, although some benchmarks measure the new language as being much faster.

Choose a version comes down to the libraries you need

Python 2 has been around longer, which can be an advantage, and not all the libraries available for Python 2 have been ported to Python 3. On the other hand, some developers are creating libraries for Python 3 that may not be compatible with Python 2. For many people, the decision whether to use Python 2 or Python 3 comes down to which libraries they want to use. Of course, if you are learning Python to work on an existing Python application, then it makes sense to learn to use whichever version of Python the software is written in.

Many people consider Python 3 to be an improved version of Python 2, as some of the updates eliminate common mistakes made by programmers (see the print example above). As described above, some of the changes have made Python 3 easier to understand for beginners. Therefore, new programmers who don’t need to use any particular libraries might want to consider learning Python 3 since there is likely to be a gradual shift to the new language over the coming years, as updates for Python 2 stop and support for the old version of the language decreases. Usage statistics shows that the number of programmers using Python 3 is already gradually increasing.

Unless there is a clear reason for choosing one version of Python over the other, such as needing to work on existing code written in Python 2, then it is not worth worrying too much about the decision. Most of the syntax is the same in each version of the language. If you ever need to switch from Python 2 to Python 3, or vice versa, it shouldn’t take too long to familiarize yourself with differences such as the changes to the print statement/function and the way Python treats integer division.

Python 3 is slowly gaining more developers

In a survey of 6,746 programmers conducted in 2014, roughly two-thirds said they write more code in Python 2 than Python 3. However, Python 3 is rapidly gaining ground; in 2013, only 22 percent of people said they wrote more code in the new version of the language.

When programmers start a personal project, just under half, use Python 3, with the rest preferring to stick with Python 2. Among the reasons for not making the switch to Python 3, people cited dependence on packages only available for Python 2 and having a large base of legacy code written in Python 2 that would need to be upgraded. Others claimed that they simply have no incentive to move to Python 3 as Python 2 meets their needs, and they are used to working with it.

Python 2 vs. Python 3: Summary

The transition from Python 2 to Python 3 is happening slowly, but it is underway. You can successfully write effective, useful and efficient code using either version of the language, so there is no need to agonize too much over which version to learn as your introduction to Python. However, it is a good idea to be aware that there are material differences between Python 2 and Python 3 in case you ever need to deal with code that is written in the version of the language with which you are less familiar.

If you are a Python programmer who is thinking of making the switch from Python 2 to Python 3, there are a few improvements in Python 3 that could make your effort worthwhile. Before porting your Python 2 project to Python 3, check that the libraries it depends on are supported in Python 3.

As time goes by, and new updates to Python 3 are released, the proportion of programmers using Python 3 rather than Python 2 is likely to increase. It is your decision whether you want to join the trend toward Python 3 now or hang on to Python 2 until the requirements of your project force you to make the switch.

The post The Key Differences Between Python 2 and Python 3 appeared first on Application Performance Monitoring Blog | AppDynamics.

Read the original blog entry...

About AppDynamics Blog
In high-production environments where release cycles are measured in hours or minutes — not days or weeks — there's little room for mistakes and no room for confusion. Everyone has to understand what's happening, in real time, and have the means to do whatever is necessary to keep applications up and running optimally.

DevOps is a high-stakes world, but done well, it delivers the agility and performance to significantly impact business competitiveness.

Latest AJAXWorld RIA Stories
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – N...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is no...
JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to compani...
DXWorldEXPO LLC announced today that Dez Blanchfield joined the faculty of CloudEXPO's "10-Year Anniversary Event" which will take place on November 11-13, 2018 in New York City. Dez is a strategic leader in business and digital transformation with 25 years of experience in the I...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE