Book Image

Python Tools for Visual Studio

Book Image

Python Tools for Visual Studio

Overview of this book

Table of Contents (13 chapters)

Preface

Like many other developers, Python developers have always had to find ways to manage the development workflow between different tools. Most of the time, this happens without using a comprehensive guide that is available in a complete IDE which is specifically designed for Python development.

The rare, exceptional IDEs that offer complete guides are often expensive and don't provide hands-on steps to help speed up the development process.

Visual Studio, as a matured and well-developed tool over the last few decades, has dominated the market of compiled languages and languages that are strictly oriented toward Windows and .NET. Packed with handy tools and functionalities to speed up and facilitate the workflow of developers, it helps users to render repetitive tasks, manage projects, and provide a detailed outlook into the structure of a project. However, most importantly, it helps users gain a clear view into the inner structure of the code.

In the last few years, Microsoft has started exploring how to integrate new languages into Visual Studio; as a result, Python Tools for Visual Studio (PTVS) was developed. It's a well-developed tool that is already on its second release and is commonly used by professional developers as their new IDE of choice for Python projects.

PTVS has everything that a Python developer can dream of: consistent project files management, interactive debugging and code completion features with the rock solid Microsoft IntelliSense technology, project templates, a first-class Django integration package, virtual environment management right in the IDE for REPL, and a native code-based IDE that loads and reacts fast.

This book will focus more on the integration of Python in Visual Studio than the language itself. It will try to delve into the power offered by the tool and venture into the feasibility of its day-to-day usage for a developer. We will show real examples of how to use PTVS with Django and how to deal with occasional difficulties when it comes to integrating well-known libraries into a Python project on Microsoft Windows.

What this book covers

Chapter 1, Introduction to PTVS, provides a high-level overview of PTVS and the interaction between Visual Studio and a Python interpreter.

Chapter 2, Python Tools in Visual Studio, provides an in-depth analysis of the tools, type checking, inner functionalities, and automatisms (IntelliSense and REPL) of PTVS.

Chapter 3, Day-to-day Coding Tools, talks about browsing through the code and the flexible setting of Python environments. It also talks about refactoring and the debugging process.

Chapter 4, Django in PTVS, shows how to harness the powerful Visual Studio IDE and tooling to speed up Django development.

Chapter 5, Advanced Django in PTVS, provides an in-depth look at remote task management and schema migrations using the third-party Python libraries Fabric and South.

Chapter 6, IPython and IronPython, provides an overview of the IPython library and how it's integrated in Visual Studio. It also provides an introduction to IronPython and its integration with the .NET framework.

What you need for this book

You will need a basic understanding of Python, a computer with Windows installed, and an Internet connection. To follow through the exercises and examples, we would suggest that you have Visual Studio as well.

Who this book is for

This book is intended for developers who are aiming to enhance their productivity in Python projects with automation tools that Visual Studio provides for the .NET community. Some basic knowledge of Python programming is essential.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

class foo:
    """
    Documentation of the class.
    It can be multiline and contain any amount of text
    """
    @classmethod
    def bar(self, first=0, second=0):
        """This is the documentation for the method"""
        return first + second

print(foo.bar())

Any command-line input or output is written as follows:

python manage.py schemamigration south2ptvs –-initial

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Clicking on the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: https://www.packtpub.com/sites/default/files/downloads/8687OS_ColoredImages.pdf

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.

Special thanks from the authors

Thanks to Packt Publishing for giving us the opportunity to publish this book for the developer community, and the help they have provided during the entire process: from the injection of the idea to the whole process of giving birth to it. It has been a journey filled with surprises and discoveries.

We'd also like to appreciate our reviewers, Fabio Lonegro and Chris Marinic, who have provided us with clear and unbiased feedback along the way, giving us great insights on untangling the details of the book.

Last but not least, we would like to thank the Microsoft PTVS team, specifically Steve Dower, who has contributed to the book personally and through providing technical support on every detail. Thanks to Shahrokh Mortazavi for reaching out to us through a tweet (https://twitter.com/cathycracks/status/421336498748006400). Steve and the rest of the team have given us lots of help, insights, and suggestions on how to overcome some complex but very important parts of the book. They even invited us to visit them in person to gain a greater insight into their work. We truly feel that PTVS is developed by a group of passionate people who care for the community and are eager to develop PTVS to be an even better and useful tool. The Microsoft PTVS team has done a great job with the tool so far in our opinion, and we look forward to what's yet to come.

We have enjoyed this journey so far, and we are very happy to be doing this together to bring this book to life. It has been an intimate and difficult process filled with love and with some very deep and long discussions into late nights. We hope that you enjoy and gain knowledge from this book as much as we have learned from it.

We hope that you will find this book interesting and that it will help you discover the inner power of PTVS, as Scott Hanselman described PTVS in a post on his blog, One of Microsoft's Best-Kept Secrets - Python Tools for Visual Studio (PTVS), created on July 2, 2013 and found at http://www.hanselman.com/blog/OneOfMicrosoftsBestKeptSecretsPythonToolsForVisualStudioPTVS.aspx.