Hands-On Application Development with PyCharm - Quan Nguyen - E-Book

Hands-On Application Development with PyCharm E-Book

Quan Nguyen

0,0
36,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

A definitive guide to PyCharm to help you build business-oriented Python applications ranging from modern web development to data science




Key Features



  • Learn basic to advanced PyCharm concepts to improve efficiency of your Python projects


  • Work through practical examples that focus on efficient application development with PyCharm


  • Explore advanced features in PyCharm such as code automation, version control, and GUI debugging



Book Description



JetBrain's PyCharm is the most popular Integrated Development Environment (IDE) used by the Python community thanks to its numerous features that facilitate faster, more accurate, and more productive programming practices. However, the abundance of options and customizations can make PyCharm seem quite intimidating.






Hands-On Application Development with PyCharm starts with PyCharm's installation and configuration process, and systematically takes you through a number of its powerful features that can greatly improve your productivity. You'll explore code automation, version control, graphical debugging/testing, management of virtual environments, and much more. Finally, you'll delve into specific PyCharm features that support web development and data science, two of the fastest growing applications in Python programming. These include the integration of the Django framework as well as the extensive support for IPython and Jupyter Notebook.






By the end of this PyCharm book, you will have gained extensive knowledge of the tool and be able to implement its features and make the most of its support for your projects.




What you will learn



  • Explore PyCharm functionalities and what makes it stand out from other Python IDEs


  • Set up, configure, and customize your Python projects in PyCharm


  • Understand how PyCharm integrates with Django for web development


  • Discover PyCharm's capabilities in database management and data visualization


  • Perform code automation, GUI testing, and version control in PyCharm


  • Integrate interactive Python tools such as Jupyter Notebooks for building virtual environments



Who this book is for



If you're a beginner or an expert Python user looking to improve your productivity using one of the best Python IDEs, this book is for you. Basic knowledge of Python programming language is expected.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 555

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Hands-On Application Development with PyCharm

 

 

 

 

Accelerate your Python applications using practical coding techniques in PyCharm

 

 

 

 

 

 

 

 

 

Quan Nguyen

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Hands-On Application Development with PyCharm

Copyright © 2019 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Commissioning Editor: Pavan RamchandaniAcquisition Editor: Alok DhuriContent Development Editor: Ruvika RaoTechnical Editor:Pradeep SahuCopy Editor: Safis EditingLanguage Support Editor: Storm MannProject Coordinator:Prajakta NaikProofreader: Safis EditingIndexer:Rekha NairProduction Designer:Alishon Mendonca

First published: September 2019

Production reference: 1270919

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78934-826-2

www.packtpub.com

                                         To my two great teachers in life: my mother, Chi Lan, and father, Bang. In memory of my grandmother and my two dear grandfathers.
– Quan Nguyen
 

Packt.com

Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Fully searchable for easy access to vital information

Copy and paste, print, and bookmark content

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Contributors

About the author

Quan Nguyen is a data scientist and Python enthusiast. He has a dual degree in mathematics and computer science, with a minor in philosophy, from DePauw University. Quan is interested in scientific computing and machine learning and enjoys incorporating technology automation into everyday tasks through programming.

Quan's passion for Python has led him to be heavily involved in the Python community. He started as a primary contributor to the book Python for Scientists and Engineers and various open source projects on GitHub. Quan is also a writer for the Python Software Foundation and a content contributor for DataScience.com. He is currently pursuing a Ph.D. in computer science at Washington University in St. Louis.

I'd like to, first and foremost, thank my parents for their incredible support throughout the process of writing this book. None of this would have been possible without their help and encouragement. Also, a big thanks to the team at Packt: Ruvika and Storm, who offered great insights that drastically improved the quality of this text; my reviewers for their excellent comments; and all others who helped to make this work possible.

About the reviewers

Luis Felipe Vera was born and raised in Caracas, Venezuela, where he received a degree in computer science from the Open National University in 2000. Subsequently, Luis Felipe completed a telecommunications specialization at Clodosbaldo Russian University and France Telecom in 2004 in Bordeaux, France.

Luis Felipe is the cousin of Blanca Vera Azaf. He is the creator of projects and applications with real-time capabilities in Django. Luis Felipe lives in Miami, Florida, with his wife, Susy, and their daughter and son, Gaby and Andres.

 

 

 

 

 

Dr. Gowrishankar S. is currently working as an Associate Professor in the Department of Computer Science and Engineering at Dr. Ambedkar Institute of Technology, Bengaluru, India. He earned his Ph.D. in engineering from Jadavpur University, Kolkata, India, in 2010, and an MTech in software engineering and a BE in computer science and engineering from Visvesvaraya Technological University (VTU), Belagavi, India, in 2005 and 2003, respectively. His current research interests are mainly focused on data science, including its technical aspects as well as its applications and implications. Specifically, he is interested in the application of machine learning, data mining, and big data analytics in healthcare. His Twitter handle is @g_s_nath.

 

 

 

 

 

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Hands-On Application Development with PyCharm

Dedication

About Packt

Why subscribe?

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Code in Action

Conventions used

Get in touch

Reviews

Section 1: The Basics of PyCharm

Introduction to PyCharm - the Most Popular IDE for Python

The background of PyCharm

The recent rise of Python

The philosophy of IDEs

PyCharm as a Python IDE

PyCharm – an essential part of the Python community

Differentiating PyCharm from other editors/IDEs

Understanding the Professional and Community editions

Prices and licensing

Further support in the Professional Edition

Choosing a PyCharm edition that fits your profession

Summary

Questions

Further reading

Installing and Configuring PyCharm

Technical requirements

Downloading, installing, and registration

System requirements

Downloading

Installing

License activation

Setting up PyCharm

General preferences

What is included in the settings

How to do it in PyCharm

Editor

What is included in the editor

How to do it in PyCharm

Keymap

The background of keymap

How to do it in PyCharm

Shortcut customizations

Getting started with PyCharm projects

Creating a project

Interacting with a PyCharm project

Getting the source code from GitHub

Summary

Questions

Further reading

Section 2: Improving Your Productivity

Customizing Interpreters and Virtual Environments

Technical requirements

Customizing the PyCharm workspace

Inside a project window

Navigating within a project

Panels in a project window

Installing packages

Moving panels within a project window

Creating a PyCharm project – revisited

Choosing a project type

Project-specific boilerplate code

Considerations about Community PyCharm

Virtual environments and interpreters

Understanding the concepts

Python interpreters

Virtual environments in Python

Virtual environments and interpreters together

Managing virtual environments and interpreters in PyCharm

Configuring the interpreter for a created project

Why does it matter?

Options in PyCharm

Importing an external project into PyCharm

Summary

Questions

Further reading

Editing and Formatting with Ease in PyCharm

Technical requirements

Code inspection

Specifics of the code analyzer

Code inspection in a PyCharm project

Dead code

Unused declarations

Unresolved references

PEP 8 style suggestions

Customizable code completion support

The case for code completion support

How is code completion different in PyCharm?

Basics versus smart code completion

Postfix code completion

Hippie completion

Intentions

Customizing your code completion engine

Match case

Sorting suggestions alphabetically

Showing the documentation popup in [...] ms

Parameter information

Intentions

Collecting runtime types

Troubleshooting

Indexing process

Power save mode

Out-of-scope files

Refactoring

What is refactoring?

Refactoring in PyCharm

Renaming

Inline variable

Extracting methods

Conversion between method and function

Exporting a function to another file

A dynamic approach to documentation

Docstrings – documentation for Python

Creating documentation

Viewing documentation

Quick Documentation

Quick Definition

Summary

Questions

Further reading

Version Control with Git in PyCharm

Technical requirements

Version control and Git essentials

What does version control mean?

Situations that require version control

Git and GitHub

Downloading Git and registering for GitHub

Setting up a repository

Add, commit, and push

Fork, clone, and pull requests

Branching and merging

Ignoring files

Version control in PyCharm

Setting up a local repository

The Version Control panel

Add, commit, and push

Branching and merging

Ignoring files

Version control diagrams

Summary

Questions

Further reading

Seamless Testing, Debugging, and Profiling

Technical requirements

Testing

Unit testing fundamentals

Unit testing in Python

Unit testing in PyCharm

PyCharm's run arrows

The Run panel in the context of unit testing

Creating unit tests with PyCharm

Tests for the Counter class

Debugging

Debugging fundamentals

Debugging in PyCharm

Starting a debugging session and the Debug panel

Placing breakpoints

Stepping functionalities

Watches

Evaluating expressions at all times

Profiling

Profiling fundamentals

Profiling in PyCharm

Summary

Questions

Further reading

Section 3: Web Development in PyCharm

Web Development with JavaScript, HTML, and CSS

Technical requirements

Introduction to JavaScript, HTML, and CSS

Understanding the importance of HTML and CSS

Writing our code with HTML

Writing our code with CSS

Understanding the importance of JavaScript

Implementing web pages in PyCharm

Using HTML and CSS in PyCharm

Creating new HTML files

Including external files in HTML code

Viewing documentation

Emmet

Viewing HTML output in browsers

Extracting HTML source code in PyCharm

Using JavaScript in PyCharm

Choosing the version for JavaScript

Hints about parameters

Debugging the code

Live editing

Specifying a framework for new applications

Summary

Questions

Further reading

Integrating Django in PyCharm

Technical requirements

An overview of Django

Django and the idea of web frameworks

What makes Django special?

Django models

Admin access in Django

Django templates

Jinja

Django versus Flask

Django in PyCharm

Starting a Django project

Structure of a Django project

Initial configurations

Running manage.py and launching the server

Creating Django models

Making migrations

The admin interface

Creating a superuser and logging in

Connecting the admin interface to models

Creating Django views

Customizing the run/debug configuration

Making templates

Summary

Questions

Further reading

Understanding Database Management with PyCharm

Technical requirements

Connecting to a data source

Working with a database in PyCharm

Working with SQL

SQL fundamentals

Using SQL in PyCharm

The PyCharm table view

Comparing and exporting query output

Diagrams for databases

Relational database

Diagrams for database objects

Diagrams for queries

Summary

Questions

Further reading

Building a Web Application in PyCharm

Technical requirements

Starting a web project in PyCharm

Creating a Django project

Creating a Django application and models

Using the admin interface

Working with the Database panel

Making queries via Python code

Creating Django's list views

Creating Django's detail views

Forms and emails

Creating the interface for the share feature

Configuring Django emails

Deploying your web project

Hosting services

Amazon Web Services

Google Cloud

DigitalOcean

Heroku

Production-specific settings

Summary

Questions

Further reading

Section 4: Data Science with PyCharm

Turning on Scientific Mode

Technical requirements

Starting a scientific project in PyCharm

Creating a scientific project in PyCharm

Setting up a scientific project

The README.md file

Installing packages

Running the code

Toggling Scientific Mode

Understanding the advanced features of PyCharm's scientific projects

The documentation viewer

Using code cells in PyCharm

Implementing PyCharm code cells

Working with CSV data

Using the CSV plugin

Summary

Questions

Further reading

Dynamic Data Viewing with SciView and Jupyter

Technical requirements

Data viewing made easy with PyCharm's SciView

Viewing and working with plots

Viewing and working with data

Understanding IPython and magic commands

Installing and setting up IPython

Introducing IPython magic commands

Leveraging Jupyter notebooks

Understanding Jupyter basics

The idea of iterative development

Editing Jupyter notebooks

Jupyter notebooks in PyCharm

Summary

Questions

Further reading

Building a Data Pipeline in PyCharm

Technical requirements

Working with datasets

Starting with a question

Collecting data

Version control for datasets

Data cleaning and pre-processing

Reading in dataset

Data cleaning

One-hot encoding

Problem-specific techniques

Saving and viewing processed data

Data analysis and insights

Starting the notebook and reading in data

Using charts and graphs

Machine-learning-based insights

Scripts versus notebooks in data science

Summary

Questions

Further reading

Section 5: Plugins and Conclusion

More Possibilities with PyCharm Plugins

Technical requirements

Exploring PyCharm plugins

Opening the plugin window

Downloading and installing a plugin

Updating and removing plugins

Best plugins to use for your PyCharm projects

Using Database Navigator

Using LiveEdit

Using the CSV Plugin

Using Markdown

Using String Manipulation

Advanced plugin-related options

Required plugins

Installing plugins from disk

Developing custom plugins

Summary

Questions

Further reading

Future Developments

Technical requirements

Miscellaneous topics in PyCharm

Using remote Python interpreters

Using macros

File watchers

Taking a step back

Improving your productivity

Web development with PyCharm

Data science with PyCharm

Moving forward with PyCharm

Using official documentation

Future updates and releases

PyCharm – the Educational Edition

Troubleshooting at a high level

Summary

Questions

Further reading

Assessments

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

This book is divided into five long sections, each covering a fundamental idea about the usage of PyCharm. In the first section, a basic introduction to PyCharm is presented. The section addresses a number of notable differences between PyCharm and other common Python editors or IDEs, comparisons between the Professional and the Community versions of PyCharm, and a step-by-step guide on how to download, register, and set up your very own PyCharm distribution on a system.

Before we turn our attention to the specifics of the PyCharm software itself, let's first consider the organization of the book. Being a comprehensive guide to a hands-on, flexible understanding of how to use PyCharm in various situations, this book contains a wide range of topics regarding PyCharm. While working on a project, most of the time, you might only be interested in a specific topic or a particular functionality of PyCharm; you are most likely not going to go through the complete book to teach yourself all the features of PyCharm (however, you are more than welcome to do so!).

Who this book is for

Any beginner or expert user of the Python programming language looking to improve their productivity via one of the best IDEs for Python can greatly benefit from Hands-On Application Development with PyCharm. Throughout this book, a basic knowledge of Python programming is assumed, together with a beginner's understanding of popular applications of Python such as software engineering, data science, and web development.

What this book covers

Here, we will go through the structure of the book and examine which specific topics are covered and where. After this, feel free to jump around the book as you look for specific features or use cases of PyCharm.

Chapter 1, Introduction to PyCharm - the Most Popular IDE for Python, introduces the general idea of an Integrated Development Environment (IDE) and PyCharm's place among the rest of the IDEs for the Python language. This chapter also distinguishes between the two editions of PyCharm: the Community Edition and the Professional Edition.

Chapter 2, Installing and Configuring PyCharm, walks you through the process of downloading, installing, and registering your PyCharm software. Afterward, a brief discussion regarding how to customize the general configurations (including the theme, editor, and shortcuts) in PyCharm is included.

Chapter 3, Customizing Interpreters and Virtual Environments, discusses the process of managing and customizing your PyCharm workspace. This includes how to arrange a project window as well as choosing Python interpreters and virtual environments.

Chapter 4, Editing and Formatting with Ease in PyCharm, offers a detailed view of how PyCharm supports the process of developing Python applications. Specifically, we will look at the features in PyCharm that facilitate important tasks such as code inspection, code completion, refactoring, and documentation.

Chapter 5, Version Control with Git in PyCharm, includes a theoretical discussion about what version control is and why it is important. A hands-on tutorial on how to facilitate version control with Git in PyCharm is subsequently included, covering concepts such as adding, committing, pushing, branching, and merging.

Chapter 6, Seamless Testing, Debugging, and Profiling, focuses on the use of PyCharm to streamline important, yet often overlooked, processes in programming such as testing, debugging, and profiling. You will gain a theoretical understanding of what these processes are as well as hands-on knowledge of the features in PyCharm that support them.

Chapter 7, Web Development with JavaScript, HTML, and CSS, starts our discussion on PyCharm in the context of web applications. Here, we are concerned with the general idea behind the web development trio languages: JavaScript, HTML, and CSS. We will explore how these languages are supported in a PyCharm environment.

Chapter 8, Integrating Django in PyCharm, introduces Django, the premier web development framework in Python. This chapter discusses what the Django framework is intended to do while also explaining a number of its most important features in the context of a web application.

Chapter 9, Understanding Database Management with PyCharm, incorporates the process of database management into the current discussion. Specifically, we will see how PyCharm assists its users during the process of working with database sources and interacting with the data included in them.

Chapter 10, Building a Web Application in PyCharm, serves as the conclusion of the topic of web development with PyCharm. By walking through a hands-on example of developing a library application, we will combine everything we have learned so far on the topic, while also introducing a few more new Django-related concepts.

Chapter 11, Turning on Scientific Mode, introduces the topic of data science and scientific computing with PyCharm. By considering a number of central features that can improve our productivity when viewing and working with data, we will see the power and flexibility that PyCharm offers to its data scientist users.

Chapter 12, Dynamic Data Viewing with SciView and Jupyter, focuses on two of the most important features PyCharm has to offer in the context of data-related projects: the SciView panel and support for Jupyter notebooks. While some programmers might assume that we will lose the ability to work with Jupyter when using an IDE, it is not the case with PyCharm, as we will see in this chapter.

Chapter 13, Building a Data Pipeline in PyCharm, plays a conclusory role for the topic of data science. Here, we will use our knowledge from the last few chapters to explore a real-life dataset, thus gaining hands-on experience of building a data pipeline, which is one of the most important jobs of data scientists in the industry.

Chapter 14, More Possibilities with PyCharm Plugins, discusses in detail and goes through some of the most popular plugins for PyCharm. What we can get out of PyCharm does not necessarily end with its built-in features; some of the time, we are able to leverage external plugins that we can add on to our current PyCharm software.

Chapter 15, Future Developments, concludes the book by introducing a number of miscellaneous features in PyCharm as well as a general discussion regarding how Python programmers should use PyCharm.

To get the most out of this book

Readers of this book should be familiar with the general syntax and practices found in Python programming, such as using variables, functions, and importing packages.

An up-to-date version of Python is required before installing PyCharm. Python 3.6 and 3.7 were the current versions at the time of writing. You are also encouraged to have a distribution of Anaconda installed.

A good internet connection is required for various parts of this book, where external tools and libraries are downloaded and used.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packt.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-on-Application-Development-with-PyCharm. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781789348262_ColorImages.pdf.

Code in Action

To see the Code in Action please visit the following link: http://bit.ly/2no4gi6.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

Section 1: The Basics of PyCharm

This section includes the first two chapters of this book. Mainly concerned with introducing readers to the idea of an Integrated Development Environment (IDE) as well as the details of PyCharm, this section will discuss various comparisons between PyCharm itself and other notable editors/IDEs in the Python community, in combination with the differences between the two versions of PyCharm available for download.

The first chapter will not go into any technical details of using PyCharm. Instead, we will analyze the purpose of using an IDE for programming projects and who (in terms of the level of competence, familiarity with Python, and so on) will benefit the most from using an IDE in general and using PyCharm specifically. The case will be made for choosing to use PyCharm over other editors and IDEs for your Python projects (given that some pre-conditions are satisfied).

The second chapter will then lay out a step-by-step guide that walks you through the process of downloading, registering, and setting up your PyCharm environment, which will put you in the optimal position to start any Python project with the full support of PyCharm.

This section includes the following chapters:

Chapter 1

,

Introduction to PyCharm – the Most Popular IDE for Python

Chapter 2

,

Installing and Configuring PyCharm

Introduction to PyCharm - the Most Popular IDE for Python

Welcome to Hands-On Application Development with PyCharm, and congratulations on taking the first step in exploring the powerful and dynamic functionalities that the most popular Python IDE, PyCharm, provides. Throughout this book, we will be familiarizing ourselves with the general interface of PyCharm, various customizations of PyCharm's functionalities to best support different types of projects, and options to integrate additional features into a base Python project.

This chapter first talks about the specifics of IDEs in programming and an overview of what PyCharm is and what its general options provide. We will then discuss the usage of PyCharm among the Python community and outline several reasons for PyCharm's popularity in the community. This discussion will help us focus on why PyCharm is such a great tool for Python programmers.

We will also be making comprehensive comparisons between PyCharm and other popular Python editors/IDEs, as well as between the paid Professional Edition and the free Community Edition of PyCharm. Any Python programmer is undoubtedly familiar with a number of different Python development tools, so these comparisons will offer a way for you to decide which edition of PyCharm is the right tool for you.

The following topics will be covered in this chapter:

The purpose of PyCharm as a Python IDE and some notable details on its developing company, JetBrains

The usage of PyCharm within the community and a breakdown of which professions tend to utilize PyCharm the most

A comprehensive outline regarding the advantages and disadvantages of using PyCharm, in comparison to other Python editors/IDEs

The differences between the Professional and the Community editions of PyCharm and the additional functionalities that the paid edition offers

On the other hand, if you have already decided that PyCharm is the Python IDE for you, feel free to jump to Chapter 2, Installing and Configuring PyCharm, to go through the installation and registration process. If you have already downloaded and successfully set up PyCharm on your system, you might want to begin at the second section of the book, starting from Chapter 3, Customizing Interpreters and Virtual Environments.

The background of PyCharm

Let's begin by discussing the topic of the book—PyCharm. First, we will discuss the Python language as it is the only reason why you would choose to use PyCharm in the first place. After this, it is important to start the conversation about PyCharm by pointing out the fact that there are considerable discussions surrounding the question of whether it is appropriate to use an IDE for Python programming.

Unlike many other programming languages, Python (as you already know) can be edited using just a simple text editor, due to the simplicity and readability of the code. You can then instruct a Python interpreter to execute a text file containing Python code and a Python program is thus complete.

Why would we want to use a heavy and complex IDE for Python to achieve the same result? In the following subsections, we will address this question by learning more about the idea of an IDE for Python and what specific problems PyCharm can help to solve.

The recent rise of Python

Python is one of the most popular programming languages out there (if not the most) by many standards and for good reasons. The user-friendliness, readability, and simple syntax of Python make it, arguably, the most accessible programming language. This is also why most colleges all over the world are redesigning their entry computer science courses to have Python as the main programming language.

The ease of learning the language leads to one of the most important factors regarding Python, which is its support community. If you are a beginner programmer, you are more likely to start out with Python, and then you will more likely make it your main programming language.

To understand how quick and efficient development in Python is, especially in comparison to other programming languages, we can turn to the creator of Python, Guido van Rossum, and see what he has to say. In a paper for the OMG-DARPA-MCC Workshop on Compositional Software Architecture, Guido van Rossum states that development in Python is estimated to be 3-5 times faster than that in Java, and 5-10 times faster than that in C/C++. Keeping this difference in mind, we can easily understand why Python is being used so ubiquitously.

You can find Guido van Rossum's complete essay here: http://www.python.org/doc/essays/omg-darpa-mcc-position/.

Obviously, the comparison between Python and Java or C/C++ is a weak one, since these languages are designed and used for different applications. However, it goes without saying that Python is relatively easier to write and develop programs with than the others, given its simple syntax.

All of these factors (and undoubtedly others) have resulted in a community that keeps growing stronger every day, taking in developers from all areas and of different backgrounds. Python libraries and packages are also being developed and released regularly, supporting a wide range of development tasks such as software engineering, video game development, web development, and scientific computing.

If you are a Python user, you are also likely to have noticed a sudden increase in Python usage in recent years. This is due to a new wave of data scientists and machine learning engineers who have recognized the advantages offered by Python over the long dominator of the field, R. In short, the Python community is growing like never before.

With numerous libraries and tools available, Python is seen as enticing by new programmers and developers who are looking for simpler ways to do various tasks, and thus, it generates more audience. I call this the cycle of Python, where its convenience attracts developers to use it for work, which in turn makes Python even more popular and easy to use. In fact, Codecademy (the premier online platform that offers interacting coding classes) noted recently that Python is the most popular language among their learners, and titled it The Programming Language of the Year (more details can be found here: http://news.codecademy.com/why-learn-python/).

The following chart also illustrates the growth of Python in recent years, in comparison to other popular languages (based on activities on Stack Overflow):

With the rise of Python observable, as stated previously, various development environments have been developed and enhanced to support its growing user community.

In the following sections, we will learn more about the background of one of these development environments, and the topic of our book—PyCharm—and why it has proven itself to be a top contender in competition with other environments.

The philosophy of IDEs

A good development environment is the first step to better productivity, and Python programming is no exception. While a beginner might be better equipped with a minimal, unintegrated environment such as Python IDLE (which comes with any Python distribution), Notepad++, Emacs, or Vim, once you have become sufficiently familiar with Python, you will undoubtedly benefit from the design and support of a good IDE.

First, let's define some terms. In the context of development environments (meaning how a programmer writes their code and develops projects), an editor typically indicates a simple, minimal text editor without any additional highlighting or aligning functionalities; on the other hand, an IDE is special software that provides such features. An intuitive comparison that I'd like to make is when we draw a parallel between programming and word processing. An editor would be a simple notepad, while an IDE would be Microsoft Word, Google Docs, or similar multi-function word processors. An IDE can have various features integrated, including syntax highlighting, automatic indention, debugging tools, and so on.

As mentioned previously, the development of some programming languages does rely heavily on the use of an IDE. This is especially true for languages where there is a considerable amount of what is generally known as boilerplate code, which is necessary for the whole program itself but does not add further logic to the program instructions. Boilerplate code is typically part of the syntax of the given programming language and is always present, regardless of what the program is designed to do.

It is in these boilerplate-code-heavy programming languages that an IDE becomes convenient, or even essential. IDEs help generate boilerplate code and appropriately place it around the core instructions that the programmer wrote, saving their time and helping them focus on the development process. This is, however, not the case for Python, a language that requires minimal boilerplate code and focuses on the actual logic of the program. In other words, once you have finished the general instructions of your Python program, it is most likely ready to be executed by a Python interpreter.

How, then, can a Python developer benefit from using an IDE? Writing Python code can be done in a sufficient way using a simple text editor, but there are other aspects of Python aside from writing code such as testing/debugging, version control, the management of environments and packages, and so on that can be boiler-plate-heavy and not quite straightforward. It is during these somewhat grinding tasks that a Python IDE can shine by streamlining them and helping developers focus on the development process.

With that said, it is not always recommended for a Python developer to use an IDE in their projects. Some have argued that relying on an IDE too much can make programmers forget, or altogether prevent them from learning, the core principles and syntax of a given programming language. Say you are asked to write a class in Python with various functionalities and methods. This is a great opportunity to take advantage of an IDE since you can import the general structure of a skeleton Python class with a single command in PyCharm (or in other IDEs). The only part left is to edit the inserted code with custom instructions according to our purposes. Throughout this process, the programmer does not need to remember, or even learn in the first place, the structure of a Python class and the syntax involved.

As such, there is a certain degree of trade-off being made when choosing to use an IDE to program, even in Python. However, you cannot argue with the fact that using a good IDE can truly improve your programming productivity, and if it enhances yours, you have every reason to use one. In general, a good strategy is to start off using a simple editor to familiarize yourself with the language and its core syntax structure. Once a good understanding of the language has been gained, you can then explore advanced functionalities that an IDE provides to see if they will be able to make you more productive. Being familiar with a text editor can also help you learn how to use an IDE faster, so that is more reason to employ this strategy.

PyCharm as a Python IDE

We have discussed the fact that an IDE for Python programming can be a solution to your productivity problem, given that you already have a solid familiarity and understanding of the language. Let's now turn our attention to PyCharm itself to see why it is a good IDE for us to learn to use.

Written in Java and Python, PyCharm was first introduced to the Python community in 2010, when the beta version was available for download. In 2013, the open source distribution of the software (called the Community Edition), which is free to download and use, was released. According to the developer, JetBrains, PyCharm operates on the following two core principles:

Improving productivity

: This is undoubtedly the most important feature of any good IDE. Again, PyCharm takes away most of the repetitive, uncreative aspects of Python programming, especially in large projects, helping programmers stay focused on the core development portion.

Real-time assistance

: It is no fun to complete a large project and realize afterward that there are inconsistencies and errors spreading all over the project code. PyCharm looks to address this problem by having an intelligent assisting feature that focuses on code completion, real-time checking logic for errors, PEP 8 code styles, and corresponding quick fixes, among other important functionalities.

From these two core principles, PyCharm also includes a number of higher-level features that help facilitate these principles. They are as follows:

Intelligent coding assistance

: As described previously, this real-time support system offers code-completion options, syntax and error analyses, as well as automated ways to refactor your code (which we will discuss further in

Chapter 4

,

Editing and Formatting with Ease in PyCharm

, in the 

Refactoring

section). The smart search option also allows you to navigate through large projects seamlessly.

Streamlined programmer tools

: Again, programming is only a part of the actual development process; most of the time, programmers have to spend their time debugging, testing, and profiling their code, as well as managing the databases and packages necessary for their projects. With a straightforward GUI, PyCharm provides a way to achieve all of this in a way that is consistent, unified, and painless.

Web development options

: As a result of the fast-growing nature of Python, web development is becoming more and more common in the community. This is why PyCharm places an emphasis on good support systems for 

web development projects, specifically,

various Python web development frameworks (Django, web2py, and Flask), as well as other major elements such as JavaScript, CoffeeScript, TypeScript, HTML, CSS, AngularJS, and Node.js. As mentioned previously, we will look at more details on the integration of these web development tools in PyCharm in section three of the book, starting from

Chapter 7

,

Web Development with JavaScript, HTML, and CSS

.

Scientific computing support

: The growth of the data science field has played an important role in the growth of Python itself, and Python is now the most common programming tool used in scientific projects (even more common than R). Notable functionalities included in PyCharm that facilitate scientific computing are the integration of IPython notebooks and an interactive console.

The support for scientific computing in PyCharm is detailed in section four of the book, starting from 

Chapter 11

Turning On Scientific Mode

. PyCharm also provides a customized view that optimally organizes workspaces in a scientific project called the

SciView

, which is shown in the following screenshot:

Visual debugging

: Two extreme stances that we programmers typically take in the topic of debugging in Python are: using print statements, which might prove to be too simple and limited in terms of expressing the changes taking place during the execution of a program, and using Python debuggers such as the

pdb

 

module,

 which can be too intimidating, and therefore inaccessible, for beginners. PyCharm offers its own solution to the debugging task—a GUI that visualizes different steps in the debugging process. In addition to being faster than

pdb

or any other current Python debugger, PyCharm's debugger allows us to view and customize changes in variables via watches and breakpoints.

Keeping the fundamentals of PyCharm's features and functionalities in mind, let's discuss the prevalence of the software in the Python community and see how its use is distributed across different professions.

PyCharm – an essential part of the Python community

In 2017, the Python Developers Survey (conducted by the Python Software Foundation and JetBrains) found that PyCharm is indeed the most popular development tool among all Python programmers in terms of editors and IDEs.

You can have a look at this survey here: https://www.jetbrains.com/research/python-developers-survey-2017/.

As observed from the Editors and IDEs section in the survey, both editions of PyCharm top the result poll for the question—what is the main editor you use for your current Python development? The results of the survey outlined that 17% of all developers used the Professional Edition and 15% used the Community Edition.

As we mentioned earlier, two of the largest subgroups in the Python community are web developers and scientific programmers. If we looked at editor/IDE use in these subgroups, we would see that the two editions of PyCharm are still the most dominant Python development environment; 30% of web developers use Professional PyCharm and 17% of scientists use Community PyCharm.

It is notable that, according to the results of the survey, other widely used editors/IDEs for Python programming are Sublime, Vim, IDLE, Atom, and Visual Studio Code. These are all viable development tools for Python programming but they might still fall short in comparison to PyCharm in a number of respects.

In the next section, we will look at a number of core differences between PyCharm and these popular editors/IDEs, and why they help PyCharm emerge as the most widely used.

Differentiating PyCharm from other editors/IDEs

We laid out several features of PyCharm in earlier sections, but it might be beneficial to repeat some of them here in comparison to other editors and IDEs in order to truly highlight the differences among them. We will start by looking at PyCharm and another powerful Python IDE (Spyder) side by side, since they generally set out to solve the same set of problems, and therefore, hold significant similarities.

In general, Spyder, like many other editors and IDEs, is a lightweight development environment. This results in less memory space, fewer system resources, and better speed in starting the software. PyCharm, on the other hand, comes as a fully supported IDE with a large set of functionalities, which will be heavier in storage and slower in execution.

In terms of support, Spyder has a simpler UI (which resembles that of MATLAB's). This can be beneficial for beginner programmers as well as people transitioning from MATLAB to Python. As for PyCharm, a comprehensive interface with different options for customization can be intimidating for unfamiliar programmers, but it can greatly improve productivity, as we have discussed and will learn first-hand in the second part of the book (Chapters 3, Customizing Interpreters and Virtual Environments, to Chapter 6, Seamless Testing, Debugging, and Profiling). However, since they are produced by the same company, users of IntelliJ IDEA specifically will also have no problem switching to PyCharm.

One previously notable way in which Spyder was superior to PyCharm was the support it offered for scientific computing, (Spyder short for Scientific Python Development Environment). The most commonly used support in Spyder is most likely the Variable explorer feature, where we have the option to inspect the value of the variables included in our program. The following screenshot demonstrates this Variable explorer feature of Spyder (please refer to this URL for more information: https://www.marsja.se/wp-content/uploads/2016/01/Spyder_variable_explorer.png):

However, this superiority Spyder had over PyCharm was only applicable until recently. PyCharm has been making some substantial improvements to its own support for scientific computing, and now it has deservedly become a serious contender to be the best scientific programming tool in Python with SciView and its other functionalities. If there is a good time to start using PyCharm for your scientific projects, then it is now!

One major difference between PyCharm and any other editor/IDE is, of course, the extensive support for complex aspects of programming from PyCharm such as version control with Git, testing and debugging, profiling, and so on. Again, the general strategy when it comes to these tasks is to first understand the foundational idea of each task and know how to do it manually before using PyCharm to automate and streamline that process. At that point, after using these support features, you will be able to appreciate the time and effort you are saving with the help of PyCharm.

Let's now take a step back and look at other editors and IDEs as well. Compared to other popular IDEs such as Visual Studio Code with the PTVSplugin (short for Python Tools for Visual Studio) or Eclipse with the PyDev plugin, PyCharm is better supported in terms of debugging and testing, web development frameworks, Jupyter Notebook and Anaconda, the real-time analysis of code, and refactoring options.

Another factor that convinces Python programmers to choose PyCharm over Visual Studio Code is its support for emulating Vim, the famous Unix text editor. Specifically, PyCharm offers a plugin that simulates the complete experience of using Vim for hardcore users. For anyone who is looking to leverage PyCharm's powerful features but still wants to keep the old Vim key bindings and interface, they can find the optimal solution with PyCharm.

A more comprehensive comparison can be found in this report (compiled by JetBrains themselves): http://resources.jetbrains.com/storage/products/pycharm/docs/Comparisons_PyCharm.pdf. Additionally, to look at different support features between most (if not all) Python editors and IDEs, you can head to this Wikipedia page: http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#Python.

Overall, the discussed features offered by PyCharm help it stand out from its competitors. While it is true that PyCharm will take up more memory space and appear uninviting to new programmers of the Python community, once you have mastered the general fundamentals of Python programming and familiarized yourself with different best practices, PyCharm will boost your productivity to another level.

I hope at this point you are somewhat convinced that PyCharm is a good IDE for Python programming. However, before heading to the website to download it, another topic that we need to discuss is the edition of PyCharm we will be using.

Understanding the Professional and Community editions

In this section, I will outline a number of the biggest differences between the two editions of PyCharm that are currently available and discuss the benefits of each edition with regard to different Python programmer subgroups.

Prices and licensing

Before you ask, yes, there are two editions of PyCharm—a free and a paid edition. The Community Edition is entirely free to download; in fact, as mentioned, JetBrains actually made the source code of the Community Edition available on GitHub in 2013.

You can find its GitHub page at http://github.com/JetBrains/intellij-community/tree/master/python.

The Professional Edition, on the other hand, has to be purchased; a license is then provided to you so that you can actually use it.

The Professional Edition can be purchased at $89.00 for the first year, with that price decreasing in the following years. However, there are ways that you can qualify for a discount, or a free license, for the Professional Edition:

If you are a student, a teacher, or otherwise work in an educational setting, you are eligible for free licensing to install PyCharm (in fact, all JetBrains tools) on your system. This applies to faculty and staff of training courses, coding schools, boot camps, and developer recognition programs (for example, active Microsoft Most Valuable Professionals, ASPInsiders, Java Champions, Google Developers Experts, and so on).

Head to this website to find out more information and register for a free license: http://www.jetbrains.com/student/ (be sure to use your organization-domain email while registering).

If you are working on an open source project, chances are you also qualify for a free distribution of PyCharm, Professional Edition. There are, however, several conditions regarding your open source project that need to be met.

Go to this website to read about these conditions and register for a license if your project meets all of them: http://www.jetbrains.com/buy/opensource/.

Former students, start-up employees, and non-profit organization members are also eligible for various forms of discount when purchasing the Professional Edition.

In the following subsection, we will be going into details regarding the additional features that the Professional Edition includes but the Community Edition does not.

Further support in the Professional Edition

In terms of the actual software differences between the two editions of PyCharm, all functionalities available in the Community Edition are included in the Professional Edition. Simply put, functionalities in the Community Edition are a subset of those in the Professional Edition.

Firstly, all the core functionalities of the GUI that puts PyCharm ahead of the competition of other editors/IDEs are fortunately available in both editions. These include the real-time code analyzer, graphical debugging features, refactoring and testing, version control, the management of packages, and virtual environments. The following screenshot shows the intelligent code analyzer (which, again, is available in both editions of PyCharm) performing a code-completion task:

Specifically, this analyzer looks at what you are typing in real time and displays a list of possible ways to complete that line of code. This can be a function/method call (similar to the previous example), variable names, or a specific syntax. This feature allows us to write code in a faster and more accurate way.

On the other hand, almost all support for web development and scientific computing projects is only included in the Professional Edition. Web development tools such as JavaScript (and its debugger) or CoffeeScript, along with Python web frameworks such as Django, Flask, and web2py are not handled by the Community Edition. In a similar manner, features that facilitate scientific computing (most notably the SciView, a variable viewer for Pandas and NumPy data structures) can only be found in the Professional Edition.

In terms of the materials covered in this book, some sections and chapters will focus on a number of features that are exclusive to the Professional Edition. Note that these chapters do not discuss only exclusive features, as there are still features available in both editions that are worth considering. For example, in section four of the book (where we focus on data science tools), the scientific mode of PyCharm and the SciView are only included in the Professional Edition, but the integration of IPython and Jupyter Notebook is applicable to both editions. In short, whichever edition you are using, it might be beneficial for you to go through all the topics that you are interested in, even if they are not supported by your Community Edition.

Additionally, a complete comparison matrix between the Community Edition and the Professional Edition of PyCharm (compiled by JetBrains) can be found on this site: http://www.jetbrains.com/pycharm/features/editions_comparison_matrix.html.

Choosing a PyCharm edition that fits your profession

So which edition of PyCharm should you choose? You may have figured out by now whether you should purchase the Professional Edition (given that you do not already have it), or simply use the free Community Edition. This will mainly depend on your own Python projects and what functionalities those projects need.

Firstly, it is possible to take advantage of all the functionalities included in the Community edition of PyCharm, whatever your profession is and whatever your project's focus is on. After all, every project can benefit from the intelligent coding assisting features and various other support features in Community PyCharm.

So, whether you are a software engineer, web developer, or data scientist, Community PyCharm will undoubtedly improve your overall productivity anyway, especially if you are working on a significantly large project.

It is important to note that, if you are working on a complex web development project that involves JavaScript, it is highly recommended that you use the Professional edition. Not only does Professional PyCharm have a powerful editing environment for JavaScript and other popular web languages, but it also offers a dedicated debugger for JavaScript, which will undoubtedly prove to be useful in your advanced web project.

Additionally, if your web applications interact with a database in a complicated manner, Professional PyCharm can help you simplify the process with the integration of various features and the visualization of data relationships in databases.

For example, say you'd like to add some data to a project by connecting to an SQLite database; you can do that in a fairly straightforward way in Professional PyCharm, as illustrated in the following screenshot:

By the same token, if you are a data scientist working with a fairly complex stack, specifically, if your projects interact with a database, it might be beneficial to take advantage of the features of the Professional Edition. The integration of IPython and Jupyter Notebook might also be a great addition to your data science workflow, but these are web-based tools that are already well-supported by web browsers such as Google Chrome. Furthermore, if your whole pipeline is designed to revolve around the web-based interface of the software, it might be worth continuing using the bare-bones Jupyter platform without PyCharm's support.

Overall, the development work you do will dictate whether it is worth it for you to purchase the Professional Edition of PyCharm or not. A good strategy is to take advantage of the free 30-day trial of the Professional Edition to see if an upgrade from the Community Edition is worth purchasing.

Summary

In this chapter, we introduced the Python language itself, as well as the background behind Python IDEs in general, and specifically, PyCharm.

We also discussed the usability of PyCharm for Python programmers. Specifically, to be able to take full advantage of all the features and functionalities that PyCharm offers without becoming too dependent on the IDE, a programmer should first master the fundamentals of the Python language and its core syntax. We also looked at comparisons between PyCharm itself and various other Python editors/IDEs and the reason why PyCharm is considered the best development environment of them all.

Finally, we compared the two editions of PyCharm that are available for download: the paid Professional Edition and the free Community Edition. If you are working with large, complex projects with many moving parts (including database management, web development languages, and view-ability in scientific reports), then you will most likely benefit from using the Professional Edition.

In the next chapter, you will learn how to download PyCharm, set it up on your system, and configure its environment for your Python projects. This will serve as the first step in getting started with PyCharm, after which, we will start discussing the specific features PyCharm offers that this book covers.

Questions

Programmers typically develop their code with an editor or an IDE. What is the difference between the two, and which one is PyCharm?

Why do some think that an IDE for Python development might be inappropriate or unnecessary?

What is the recommended strategy for using an IDE for Python development?

What are some key features of PyCharm? Of those features, which give PyCharm an edge over other editors/IDEs?

What are the two editions of PyCharm? What are the key differences between them?

Who should use the Community Edition of PyCharm? Who should use the Professional Edition of PyCharm?

Further reading

For more information, you can refer to the following literature:

PyCharm, The Python IDE for Professional Developers

, JetBrains s.r.o. (

https://www.jetbrains.com/pycharm/

)

Text Editors vs IDEs for Python development: Selecting the Right Tool

, by Jason Fruit, (

https://www.pythoncentral.io/text-editors-vs-ides-for-python-development-selecting-the-right-tool/

)

Mastering PyCharm

, Quazi Nafiul Islam, by Packt Publishing (

https://www.packtpub.com/in/web-development/mastering-pycharm

)

Python Developers Survey 2017 Results

, JetBrains s.r.o. (

https://www.jetbrains.com/research/python-developers-survey-2017/

)

How does PyCharm match up against competing tools?

, JetBrains s.r.o. (

https://resources.jetbrains.com/storage/products/pycharm/docs/Comparisons_PyCharm.pdf

)

Installing and Configuring PyCharm

In the previous chapter, we looked at the most popular features of PyCharm and considered some of the reasons why a programmer may find using PyCharm useful and productive. This chapter, in turn, provides a step-by-step walk through of the installation of PyCharm on a computer system, including the process of registering for a license for the Professional edition.

As PyCharm is a highly customizable tool, a considerable amount of initial configuration is typically necessary, which this chapter will tell you about in detail. Productivity-related customizations such as keymap and shortcuts will also be discussed. Finally, we will talk about the process of downloading the code that is used as examples in various chapters of this book.

The following topics will be covered in this chapter:

Downloading, installing, and configuring PyCharm in a computer system

Customizing projects, keymap, and shortcuts within PyCharm

Downloading the code repository used in this book from GitHub

Technical requirements