Sie sind auf Seite 1von 6

IMAGE: JAMES SANDERS/TECHREPUBLIC

PYTHON PROGRAMMING
LANGUAGE: A CHEAT SHEET

By James Sanders

COPYRIGHT ©2019 CBS INTERACTIVE INC. ALL RIGHTS RESERVED.


PYTHON PROGRAMMING LANGUAGE: A CHEAT SHEET

With over 8.2 million developers using Python, the popularity of the Python programming language can’t be
denied. Since the first release in1990, Python has gained public support in academia and business, being used
extensively in artificial intelligence and machine learning, serving as the underpinning of OpenStack, as well as
powering the cloud file storage service Dropbox.

This extensibility makes Python an excellent programming language for junior developers to get started with,
but also one that remains applicable at scale, as Python is used extensively for real-world applications. This
cheat sheet explores what Python is used for and how it compares to other programming languages, and
provides resources for learning the language.

WHAT IS THE PYTHON PROGRAMMING LANGUAGE?


Python is an interpreted programming language (also called a scripting language), created in 1990 by Dutch
programmer Guido van Rossum, following his experience working on the education-focused ABC language at
CWI. Python differs from other programming languages, as it prioritizes code readability and use of whitespace
over compact, tiny source files.

Python is dynamically typed and garbage-collected (through reference counting and cycle detection), supports
object-oriented and structured programming fully, and largely supports functional and aspect-oriented
programming, making it particularly versatile and applicable for a wide variety of use cases.

The standard library is commonly considered one of the greatest strengths of Python; this feature enables
programmers to quickly develop projects without needing to rely heavily on third-party packages for the
basic plumbing of a given application. To complement the standard library, the Python Package Index (PyPI)
catalogues over 200,000 packages that provide various functions.

WHAT MAKES PYTHON A GOOD CHOICE FOR MY PROJECT?


Python’s design as a language makes it a good choice for projects with multiple authors, as the inherent
readability of the language aides in the ability to pick up code and clearly understand how it operates. Python is
a powerful programming language, enabling even junior developers to accomplish quite a lot—as is the case for
practically everything in computer science, there is an xkcd for that.

Python is used extensively in artificial intelligence; Google’s TensorFlow framework includes Python modules,
as does Keras and Scikit-learn. The Anaconda project is a distribution of Python and R for scientific
computing. IBM’s Qiskit and D-Wave’s Ocean learning platforms also use Python for programming quantum
computers. Python is used by data scientists, with popular libraries including NumPy, SciPy, and Matplotlib, and
in web development frameworks including Django, CherryPy, Pyramid, Flash, web2py, and webapp2.

2
COPYRIGHT ©2019 CBS INTERACTIVE INC. ALL RIGHTS RESERVED.
PYTHON PROGRAMMING LANGUAGE: A CHEAT SHEET

Graphics editing programs also use inline Python scripting, including the 3D animation software Autodesk 3ds
Max, Maya, and MotionBuilder, as well as Cinema 4D, Lightwave, Houdini, and modo, the Nuke compositor,
and the open source Blender toolset. Of 2D graphics software, PaintShop Pro, as well as the open-source
software GIMP, Inkscape, and Scribus.

Additionally, LibreOffice uses Python for inline scripting, much in the same way Visual Basic is used to extend
features of Microsoft Office.

In 1999, software developer Tim Peters, a major contributor to Python and creator of the original CPython
implementation, wrote the “Zen of Python,” an explanation of Python’s design philosophy, and the philosophy
that programmers should incorporate into their programming approach. The document was later incorporated
into official Python documentation.

Beautiful is better than ugly.


Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one—and preferably only one—obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea—let’s do more of those!

3
COPYRIGHT ©2019 CBS INTERACTIVE INC. ALL RIGHTS RESERVED.
PYTHON PROGRAMMING LANGUAGE: A CHEAT SHEET

HOW DOES PYTHON COMPARE TO OTHER


PROGRAMMING LANGUAGES?
Python can be used for practically any use case that any other high-level language (C/C++, JavaScript, PHP,
etc.) can be used for. Implementations for modern microcontrollers exist, though older CPUs (m68k, z80,
6502) cannot use Python.

While the CPython reference implementation is broadly useful for most use cases, other Python interpreters do
exist to address specific needs and deployment scenarios. MicroPython is a microcontroller-focused implemen-
tation supporting Arm architectures, in addition to Arduino, ESP8266, ESP32, and RISC-V (32- and 64-bit)
architectures. CircuitPython is an education-focused fork of MicroPython.

PyPy is the most popular general-purpose alternative implementation of Python. It differs from CPython in
that PyPy is a (faster) just-in-time compiler, while CPython is an interpreter.

Language-target implementations also exist, including CLPython for Common Lisp, IronPython for .NET/
Mono, and Jython for Java. Likewise, the Nuitka project is a source-to-source compiler from Python to C/C++
source code.

WHAT IS THE DIFFERENCE BETWEEN PYTHON 2


AND PYTHON 3?
The Python 3.x series was introduced in December 2008, addressing and rectifying fundamental design flaws, as
well as generally modernizing the language. Python 3 was developed with the guiding principle of “[reducing]
feature duplication by removing old ways of doing things.” Due to this, Python 3 is not fully backward-com-
patible with Python 2, requiring developers to modernize their code to run on the new version.

Support for Python 2.7 is ending on January 1, 2020, making the transition to Python 3 all the more urgent.

For programmers, tool-assisted porting using futurize or modernize can aid in the transition, while the
caniusepython3 project shows what legacy dependencies may be blocking you from using Python 3.

HOW DO I GET STARTED PROGRAMMING IN PYTHON?


Learning Python doesn’t require getting a degree in computer science—there’s a wealth of resources available
online to help users get started with the programming language.

TechRepublic Academy, a joint venture between TechRepublic, ZDNet, and StackCommerce, also offers a wide
variety of in-depth Python training courses.

4
COPYRIGHT ©2019 CBS INTERACTIVE INC. ALL RIGHTS RESERVED.
PYTHON PROGRAMMING LANGUAGE: A CHEAT SHEET

If you’re already familiar with programming, chances are your IDE of choice either natively supports Python
or support can be added using a plugin. For new programmers, using a free IDE that supports Python is a
quick way to get started—these include Atom, PyCharm, Geany, Sublime Text, and Visual Studio Code.

5
COPYRIGHT ©2019 CBS INTERACTIVE INC. ALL RIGHTS RESERVED.
CREDITS
Editor In Chief ABOUT TECHREPUBLIC
Bill Detwiler
TechRepublic is a digital publication and online community
Editor In Chief, UK that empowers the people of business and technology. It
Steve Ranger
provides analysis, tips, best practices, and case studies
Associate Managing aimed at helping leaders make better decisions about
Editors technology.
Teena Maddox
Mary Weilage DISCLAIMER

Editor, Australia The information contained herein has been obtained


Chris Duckett from sources believed to be reliable. CBS Interactive Inc.
disclaims all warranties as to the accuracy, completeness,
Senior Writer
Veronica Combs or adequacy of such information. CBS Interactive Inc. shall
have no liability for errors, omissions, or inadequacies in
Editor
the information contained herein or for the interpretations
Melanie Wachsman
thereof. The reader assumes sole responsibility for the
Staff Writer selection of these materials to achieve its intended results.
James Sanders The opinions expressed herein are subject to change
Associate Staff Writer without notice.
Macy Bayern

Multimedia Producer
Derek Poore
Copyright ©2019 by CBS Interactive Inc. All rights reserved. TechRepublic
Staff Reporter and its logo are trademarks of CBS Interactive Inc. ZDNet and its logo are
Karen Roby trademarks of CBS Interactive Inc. All other product names or services
identified throughout this article are trademarks or registered trademarks of
their respective companies.

Das könnte Ihnen auch gefallen