 Welcome to Visual Studio 2019. My name is Tyreek White and I'm a program manager for Python Developer Tools in Visual Studio. The release of Visual Studio 2019 marks the introduction of some amazing new features to enhance the Python Developer experience. These include the ability to bring your own pre-existing Python code through open folder support and without the need to create a Visual Studio project. We've introduced a Python toolbar, which appears whenever you open a Python file. The toolbar allows you to create virtual environments as well as Conda environments and manage packages within those environments. We now include mini Conda by default within the Visual Studio installer. This decreases installation times, enabling you to get started more quickly with your code and to create Conda environments without the need to install Anaconda. Finally, in this release of Visual Studio, you can now use LiveShare to share your Python files with your peers, and collaboratively work with them to debug your code. But showing is better than telling. So let's dive in and explore these new features. So now let's demo open folder support in the Python toolbar in Visual Studio 2019. When you open Visual Studio 2019, you're given the welcome home page, which allows you to get started with code by either cloning or checking out from a repo, opening a project or solution, opening a local folder or creating a new project. I'm going to open my Flask Web App that I've been working on, which is here. So now that my Flask Web App is open, let's explore it a bit more. As you can see, I'm given the Solution Explorer view here on the right-hand side, and this shows me all of the folders and files that compose my project. An important thing to note about this project is the requirements.txt file. This includes all of the packages and dependencies that my project will need to function correctly. As well, these are the packages that IntelliSense will be using to provide auto-completion, as well as syntax highlighting, and all of the good stuff we know and love. So what we need to do now in order to be able to run this Flask app is to create a virtual environment that has all the packages contained within this requirements.txt file. To do that, we're going to use the new Python toolbar, which is here. I'm going to click the drop-down arrow. I'm going to scroll down until I find AdEnvironment, click that, and it brings up the AdEnvironment dialog. From here, I can name my project, I can select the base interpreter for my project, let's use Python 3.7, and I can install packages from file. Notice that it's finding that requirements.txt file I showed you a moment ago, but if I'm not satisfied with that file, I can choose another by clicking here. By default, we select Set as Current Environment, because when I create this virtual environment, I'm going to be loaded straight into it without the need to do anything additional. So let's go ahead and create this Flask demo environment. Now that we're loaded until our virtual environment, let's explore it a little bit. A new feature that we've added is the Manage Package icon in this environment, which is located beside the Python toolbar here. Clicking this icon brings you straight into the Python Environments tab. From here, you can explore all of the different virtual environments you have created within your machine, and you can see all the packages that are included within the current virtual environment, and these should all look familiar because these are exactly the packages I installed from the requirements.txt file a moment ago. But if I realize that a package isn't here that I want, we can use PyPI and simply type in the package name, and install it. So what I'm going to do is install requests. Voila, we now have requests in our virtual environment and we can see it here. So now let's demo this Flask app. So what I'm going to do is I'm going to add a date URL because I'm interested in going to a URL that tells me today's date as well as the current time. To do that, I'm going to go to this routes.py file that I have here, and I'm going to create a route for date. So let's do that now. As you can see, the IntelliSense starts kicking in, and let's define date, and let's let date be equal to getDate, which is a function I pre-created at the top of this file. Finally, for this route, we need to return renderTemplate. As you can see, the IntelliSense finds that, and it tells me what I should pass in. So I need to pass in an HTML, which I've already created called date, as well as our date object we just created. I'm going to save this, and let's start this application, and I'm going to grab this URL here, and I want to go to the date URL that we just created. Hello there, it's Friday, March 29th, 2019, and it's 10.54 AM. Now let's debug this date URL because I want to show everyone the cool features we have to offer for debugging. So to initiate a debugging session in Visual Studio, I can either press F5 on my keyboard, or I can press the green arrow here. So I'm going to press F5, but you can press the green arrow. When I initiate that debugging session, it's going to take me to the first breakpoint that I've set, which is my import statement at the top. With debugging in Visual Studio, you have all of the features we know and love such as step into, step over, step out of. But I have another breakpoint set inside of my date URL that I'm interested in debugging. So to continue to that next breakpoint, again, I can press the green arrow or F5 on my keyboard. Because I set the breakpoint inside of a URL in order to actually hit that breakpoint with this Flask Web App, I'm going to have to go to the browser and type in that date URL once again. Cool. Now that I've hit the breakpoint, you can notice that date equals get date, where get date is a function I've defined at the top of this file. So let's actually step into this get date function to explore it a bit more, which I can do by going to my debugging toolbar and pressing step into, right here, or F11. So now that I've stepped into get date, you can see that date is equal to date time dot now. What's cool is that now that I'm inside of this function, if I step over where I define date, notice that the locals window pane becomes populated with the date object as well as the value and the type, which is the date time object. Or I can also get this information by hovering over date and day 29, as well as the minute, even down to the microsecond. Pretty cool. If I want to step out of this function get date, I have two options. I can either use the step out command from the toolbar, or I can scroll down to the line I'm interested in running to, and notice that when I hover beside that line, this green arrow appears and this is called the click to run button, and I can press this and the app finishes to completion. Hello there. Visual Studio 2019 allows you to bring your own code no matter the scenario. So you also get all the same functionality, even if the Python file is embedded within a larger project like a C++ project. What's great is that their support for mixed mode debugging and IntelliSense to make you even more productive in those scenarios. As I mentioned earlier with Visual Studio 2019, you can bring any Python code no matter the scenario. So now what we're going to do is I'm going to show you guys a script called Mandelbrot.py, which creates and plots a Mandelbrot set. So as you can see, I'm loaded to my familiar page, I have the solution explorer, and notice that Mandelbrot.py has one package dependency, and that's NumPy. So again, I'm going to create a conda environment for this package, but keep in mind that you can create a conda environment for a different arrangement of packages. This one just only happens to use NumPy. So again, I'm going to go to the Python toolbar, go to Add Environment, but this time I'm going to select conda environment on the left-hand side. I'm going to name it, let's call it Test, and I can add packages from a YAML file, which is a popular conda package file. Or what we've added is the ability to add one or more anaconda package names by either typing them in the search bar here or using this icon. When you click this Add Packages icon, you'll notice that we've bucketed the different popular Python workloads into things such as data science core libraries, which is where NumPy lives, visualization, machine learning, and a web workload, which has Django Flasks and requests. So I'm going to select NumPy, but also keep in mind that if this conda environment or if this Mandelbrot script needed TensorFlow for example to run, I could type it in the box here, and it would give me a preview of all the packages that will be installed within my conda environment, and then I hit Create. So now that I've created my conda environment called Test, let's do some more exploration. So if I go to the Python environments tab, recall that I said that this Mandelbrot plot script is going to create and plot a Mandelbrot script. If I want to plot this in an IPython interactive experience, one thing I can do is find my conda environment test, go to this icon which opens the interactive window, and drop down to this option which says, use IPython interactive mode and hit the checkbox. So that way I can get the inline figures graphing that a lot of us know and love. Nice. Now we're ready to explore this script. In order to start running this script, there are a couple of ways I can run it. I can select lines that I'm interested in from this code. So let's select this import statement. I can right-click and find the option that reads send to interactive and notice that it sends the import statements in the interactive window and there are no errors, which is great. Another way to run this is to select the lines I'm interested in again, but this time I can use Control-Enter. As you can see within the interactive window, it sends the two code snippets to the window and it replies hello world. Again, no errors. To be even more productive in these interactive scenarios, another neat trick you can do is to decorate different sections of code with pound percent percent. That way you can send these sections of code iteratively to the interactive window for further inspection. So as you can see, I've decorated different sections with pound percent percent, and I'm going to send these chunks to the interactive window piece by piece. I can do this again by right-clicking over a section and selecting send to interactive, or I can just use Control-Enter. So I'm going to use Control-Enter. We send that snippet as well as that snippet, this snippet, and that snippet. Notice the warnings that pop up but not a big deal at all. Now I'm ready to show you guys what this Mandelbrot plot actually looks like. So starting from the top, I'm going to use Control-Enter and send everything to the interactive window. There it is, our Mandelbrot plot. What's great about the inline figure graphing is that, if I see something is off with my figure, I can compare my figure with my code and send it back to the interactive window. No need for additional pop-ups or dialogues for plots. Finally, there is now LiveShare support for Python and Visual Studio 2019 to enhance your collaborative coding experience. In VS 2019, you can initiate a LiveShare session by clicking the LiveShare button on the upper right corner of Visual Studio to generate a link to share with your peers. Users who join your LiveShare session will be able to see your Python files, see IntelliSense from your selected Python environment, and collaboratively debug through your Python code all from their own machine. There you have it, Visual Studio 2019 brings some powerful sleek tools that will enable you to bring your own Python code wherever you may be. Are you ready to get started? Check out the links here for more info. Happy coding.