Python on Windows, Like a Boss
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 160 | |
Author | ||
License | CC Attribution - NonCommercial - ShareAlike 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Identifiers | 10.5446/33770 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
00:00
Boss CorporationSoftwareIntelCoding theoryVisual systemGoodness of fitCycle (graph theory)Software developerDifferent (Kate Ryan album)WindowFormal languageMathematicsReading (process)Virtual machineElectronic mailing listPoint (geometry)Water vaporDisk read-and-write headProjective planeSoftware frameworkBitAdditionMetrePerspective (visual)Library (computing)Boss CorporationForcing (mathematics)Cartesian coordinate systemRight angleType theoryPhysical lawMusical ensembleFrame problemComputing platformMereologyCommutatorAdhesionMatching (graph theory)Staff (military)BuildingTournament (medieval)Network topologyKey (cryptography)CASE <Informatik>Video gameOpen sourceStack (abstract data type)DialectException handlingVisualization (computer graphics)Enterprise architectureComputer configurationHacker (term)Data storage deviceSemiconductor memoryOffice suiteFunctional programmingExtension (kinesiology)Core dumpIntegrated development environmentInstallation artEmulatorC sharpText editorKeyboard shortcutFreewareArithmetic progressionAuthorizationValidity (statistics)Concurrency (computer science)WordLecture/ConferenceMeeting/Interview
08:05
Electronic mailing listVideoconferencingVirtual machineDistribution (mathematics)Different (Kate Ryan album)Revision controlSoftware developerWorkloadCuboidFlow separationHTTP cookieImage resolutionTemplate (C++)Installation artVisualization (computer graphics)Computer animationLecture/Conference
09:24
Template (C++)Data managementVirtual realityThumbnailWebsiteView (database)WebsiteData managementPosition operatorIntegrated development environmentDialectVisualization (computer graphics)Demo (music)Virtual realityTemplate (C++)
10:14
Multiplication signCartesian coordinate systemPiSubsetPersonal identification numberFormal languagePhysical systemPoint (geometry)Endliche ModelltheorieIntegrated development environmentMathematical analysisCASE <Informatik>Electronic mailing listInterpreter (computing)CyberspaceComplete metric spaceLine (geometry)Projective planeGame theoryGodNetwork topologyCuboidComputer fileBeat (acoustics)Medical imagingOffice suiteLatent heatWeb browserRevision controlSource codeDifferent (Kate Ryan album)WindowMathematicsCodeInternet forumQuicksortCycle (graph theory)Slide ruleOpticsKeyboard shortcutBranch (computer science)Menu (computing)Identity managementSet (mathematics)Computer configurationCategory of beingStress (mechanics)Template (C++)NumberInformationProduct (business)Standard deviationVisualization (computer graphics)BitDefault (computer science)Scripting languageRight angleDynamical systemDemo (music)Sinc functionOpen setMobile appCache (computing)Flash memoryExterior algebraWorkloadSpherical capVideo game consoleVirtual realityLecture/Conference
19:56
Execution unitSoftware testingGame theoryUnit testingInterface (computing)Software testingExecution unitUniverse (mathematics)Visualization (computer graphics)CodeC sharpPower (physics)Software bugSystem call
21:01
Server (computing)Source codeEndliche ModelltheorieComputer configurationOffice suiteCodeMobile appVisualization (computer graphics)YouTubeComputer animation
21:36
Integrated development environmentRepository (publishing)Source codeControl flowCodeGame theoryDemo (music)CodeProjective planeComputer fileVisualization (computer graphics)Integrated development environmentMultiplication signRevision controlPoint (geometry)Source codeComputer configurationRepository (publishing)Observational studyTwin primeNoise (electronics)AdditionSystem callCore dumpProcess (computing)JSON
22:50
Vector spaceSpeech synthesisOptical disc driveLimit (category theory)Right angleComputer programmingMathematicsWindowState of matterSystem callPoint (geometry)Variable (mathematics)Water vaporVirtual machineProcess (computing)NumberFile systemMultiplication signPhysical systemElectronic mailing listCloningCartesian coordinate systemSummierbarkeitComputer fileExecution unitKey (cryptography)Functional (mathematics)Web pageWeb browserMassSource codeVelocityError messageCASE <Informatik>Automatic differentiationWebsiteType theoryCyberspaceDisk read-and-write headSemiconductor memoryText editorView (database)Game theoryTemplate (C++)Computer virusServer (computing)Link (knot theory)Equaliser (mathematics)Home pageTupleMobile appVisualization (computer graphics)Message passingEmulatorRoutingArtificial lifeLecture/Conference
30:20
Multiplication signVisualization (computer graphics)CodeSoftware testingServer (computing)Condition numberPower (physics)CloningComputer configurationExecution unitImage resolutionScripting languagePoint (geometry)Unit testingMobile appLine (geometry)2 (number)Projective planeControl flowPhase transitionEndliche ModelltheorieCyberspaceCASE <Informatik>Cartesian coordinate systemNetwork topologyComputer fileRight angleSystem callMereologyVector spaceVirtual machineLecture/Conference
35:41
Game controllerPoint (geometry)StapeldateiLoop (music)Multiplication signReplication (computing)Power (physics)Software developer2 (number)Projective planeIntegrated development environmentGame theoryTouchscreenLine (geometry)Sound effectNumberVisualization (computer graphics)CodeClosed setVideo gameSoftware testingWindowLogicWater vaporNormal (geometry)Computer programmingComputer fileFlow separationMeromorphe FunktionFunctional (mathematics)Right angleInterpreter (computing)Directory serviceVirtual realityServer (computing)Graph coloringOpen setHeegaard splittingScripting languageGastropod shellGoodness of fitSource codeLecture/Conference
40:51
Point (geometry)Sheaf (mathematics)WebsitePerformance appraisalNormal (geometry)Sound effectProduct (business)Link (knot theory)Visualization (computer graphics)Demo (music)WindowYouTubeProjective planeSlide ruleLecture/ConferenceComputer animation
41:56
Touch typingCrash (computing)WindowWordVisualization (computer graphics)Connected spaceSoftware developerWritingSoftware testingInclusion mapInstallation artUnit testingVirtual realityVirtual machineInternetworkingPlanningDifferent (Kate Ryan album)Cross-platformRevision controlElectronic mailing listMereologyVideo gameSystem administratorExecution unitExtension (kinesiology)Projective planeGraph coloringObject (grammar)Term (mathematics)Integrated development environmentLecture/Conference
Transcript: English(auto-generated)
00:04
Well, good morning everybody. Thanks for coming and listening to my talk. So let's start with the title. You know it already. Let's start with who I am, which is kind of the point of this talk,
00:20
because I've been called a weirdo once by a guy to whom I was explaining what I do. Can you actually read there? It's not really important, I'm going to tell you. So I work on Python, of course. I do a lot of Python. You may know some of my open source projects. I am the author of the EVO-REST API framework, which is based on Flask,
00:46
and also Cerberus, which is a data validation library for Python. Both have quite a following and a community around them. But also I do a lot of stuff in C Sharp and other languages, and I lead the development of an accounting application in my own country,
01:05
and that's basically all the C Sharp and F Sharp functional languages and stuff like that. I got a few awards. I'm also very active in the development community in Italy, but that's not really relevant for this talk.
01:21
What really matters is that I do multiple languages, and this takes me, especially on Windows, on weird lands, where basically I've been forced, until a few months ago or years ago, to work on different platforms.
01:41
As you can see, I'm speaking about Python on Windows, but I'm using a Mac here, which is kind of weird to begin with. I'm doing Python development into a virtual machine on OS X, OS X 10 host, which is kind of weird, again. So when I do Python, I use all the typical Python stack stuff,
02:06
so I use Vim for text editing, iTerm, Bash, OS X, or Linux, depending on if I'm SSHing somewhere else or not. So I'm the typical Linux hacker. But then, when I work on C Sharp, I'm forced to work on Visual Studio,
02:27
which is, by the way, an awesome IDE, but if you are using text editors and Vim, you are probably not really fond of IDEs. I hope that this talk will kind of change your mind about that.
02:42
I also use a phenomenal Vim emulator for Visual Studio, so at least I can enjoy Vim key bindings in my favorite IDE. So if you use Visual Studio and you also like Vim, look it up.
03:00
It's called OS Vim. It's a wonderful extension for Visual Studio. And yes, I work on the development framework, and of course I work on Windows. And that's been the story basically of my life, working on different platforms one day, the other day, or even by night and by day on a different platform.
03:21
So basically a nightmare. If you are like me and happen to work on different stacks, you know all about this. Just out of curiosity, how many of you work on Windows machines? Oh, wonderful. And how many of you do Linux on Windows machines?
03:42
Well, quite a few, so it's not bad, not bad at all. And do you also do other languages like C-Sharp or maybe other languages, maybe not C-Sharp? Great. How many are using Visual Studio? C-Sharp, sorry. Great. C-Sharp, guys. So you see, it's quite a different word, a varied word, and again, the point of this talk basically is there are different stacks for different languages,
04:05
which is kind of strange in my opinion, shouldn't be like this. So I needed something, something that could kind of make these two different words collide, converge in some way so that I didn't have to switch back and forth between these stacks.
04:23
We are not quite there yet, to be honest, but we are making progress, and quite impressive progress in my opinion. The most relevant, for me at least, release that changed the way I work on Python lately has been the Python tools for Visual Studio.
04:42
So if you are a C-Sharp guy, you probably are kind of forced to use Visual Studio. If you are not a C-Sharp guy, probably you heard about Visual Studio, good and bad things probably, but I believe it can be a nice interesting option right now,
05:01
Windows, not only for C-Sharp, F-Sharp, TypeScript, but also for Python, and this is very interesting. By the way, Visual Studio, or I should say the Python tools for Visual Studio are open source. You can go on GitHub and contribute to the project. It's made with love by a guy, not only a guy, it's a small team within Microsoft,
05:23
but the interesting part here is that they are also core contributor to Python. In particular, Steve Dower, which is the lead project of Python tools for Visual Studio, he's a core developer of Python, so he kind of knows the deal. He knows what Python is.
05:41
The point is we are not talking about Microsoft corporate guys assigned to do something just because we need Python in Visual Studio, but we have a core developer wanting to use Python in Visual Studio, and it changed the perspective completely for me. It makes everything more interesting. And also, lately, a few years ago, Visual Studio was released in a community edition,
06:05
which is actually 100% free to use. There are some caveats, and here they are. You can use it for education purposes. You can use it for free for open source projects. You can use it if you are an individual, even if you do that for business.
06:23
So if you can build applications in Visual Studio, sell these applications commercially, no problem, you can use it for free. And small teams, up to five people, working concurrently on Visual Studio, and the key here is concurrently. It means you can even have 20 people using Visual Studio Community Edition,
06:40
not a problem, as long as they don't work concurrently. So it makes Visual Studio, the free edition of Visual Studio, quite usable for a lot of use cases, in my opinion. For example, in my company, it is just six of us. We can use Visual Studio Community Edition. There are no differences between the Community Edition and the Professional Editions,
07:01
so you basically have all of Visual Studio. The only exception is the Enterprise Edition, which has a few advanced options, but it's quite usable for everything you need to do, especially if you want to work in Python. So let's give a look at the features. I'm going to demo some features.
07:20
I hope it won't bomb on me, so follow me along and let's hope everything works out. So the first thing I want to tell you is that Python, historically, if you do Python on Windows, and I've been doing that for a while, you probably know that it wasn't that easy to do Python on Windows. If you had to install something, and then probably if you wanted to use Git,
07:44
you also had to install something else, and that strange thing is called Git, I don't remember the name right now, but it is basically an emulator of Bash for Windows, so you could use Git on the command line. Yes, there was some work to be done, especially some years ago.
08:02
Now, Visual Studio offers you an interesting experience. I'm going back to VirtualBox here, and I wanted to show you the Visual Studio installer. Here you see that when, unfortunately, we have a very low resolution here, so I hope you can, but you probably can read very well,
08:21
but I have to scroll a lot. So you see here that when I install Visual Studio, I can choose to install the Python development tools, and this will install Python for you if you don't have Python on the machine, which is very interesting, especially for beginners, so for people coming from Visual Studio and C Sharp,
08:41
people who don't know much about Python and stuff like that, and as you can see, there are interesting templates here. You can install several Python distributions, for example, Anaconda or Cookie Cutter, and yeah, different versions of Python, and everything is installed seamlessly, together with Visual Studio,
09:00
or if you have Visual Studio already installed, you can just go in the installer and add the Python workload, and it will install everything for you. So you don't have to do any kind of strange things, go to the command line or download the executable of Python and launch it. Now, probably for the most of you, this is not an issue, but for people new to the language, this is very interesting, I believe.
09:27
And then we have a lot of templates readily available, we will see them in the demo in a few minutes, and then we have package management support directly into Visual Studio,
09:41
so here we are seeing somebody trying to install Django within its own project, and there is support for virtual environment, so even creating a virtual environment, and installing packages via PIP, you can do that from within Visual Studio as well. And let's try and build a website with Python,
10:03
since we had Armin here last year at the conference, not in the room probably, let's build a Flask website, for example, by using Visual Studio. So let me switch back to VirtualBox. Let's go to a clean Visual Studio installation here.
10:22
If I go to the File menu, oh, by the way, there are other options, if you want to do Python in Windows, for example, since most of you are Python guys, probably you know PyCharm, for example, which is a super cool, very nice, big shout out for PyCharm, it's a very nice project, but in my case,
10:40
what I do every day, as I told you, is C Sharp, so I wanted to use my own IDE for Python as well. But if you don't fancy Visual Studio, you can look at alternatives like PyCharm, which is very nice, or Visual Studio Code, for example, is a super nice product. It's not really an IDE, more a text editor, but very powerful and is gaining a lot of traction later,
11:02
also in the Linux community, so very interesting. So if I start a new project, and I installed the Python workload for Visual Studio, when I go to other languages, I can pick Python, and as you can see, there are a number of templates. You see that there are templates for Bottle,
11:21
for Django, for Flask, and also, of course, console applications and stuff like that. There are a lot of them. I run Python, if you fancy that, Pygame, et cetera. Now we are going to build a Flaskware project. As you can see, there is a preview here. I just hit OK.
11:41
And this is very nice, in my opinion. As you can see, if I go here to the Solution Explorer, I can't because the Windows is a model, of course, but Visual Studio knows that I need to install some stuff from PIP, and it offers to create a virtual environment for me for my own project. So as you can see, the support for a virtual environment
12:02
is built in, and I could click here, and it will ask me, what do you want to call this virtual environment? I am in this case, and I pick the interpreter version. It picks up the different Python versions installed on my system.
12:21
In this case, I should pick up 3.5 32 bits because Visual Studio here is 32 bits. And as you can see here, it offers to download and install the packages for me. It can do that because the template includes a requirements file, requirements.txt, as you probably know everything about it.
12:41
So it will go and download the requirements for this project. Now, I'm not going to do this right now here because I don't want to risk the Wi-Fi to crash on me. I have here, you can see that here, even if I abort the installation, I have my code ready. But let's go back to this one,
13:04
EuroPython demo, basically the same exact project. But as you can see, if I go in Python environments, I have an environment based on Python 3.5. And if I open this branch here, I see that all flash dependencies are already installed for me.
13:20
And this is, of course, a local environment just for this project. I could go here. Let me see if it works. And this will be an open folder in File Explorer. As you can see, we are in the EuroPython demo folder, and we have an AMP folder. And here are all the packages for my app.
13:44
So just local to my own project, like you would do on the command line on Linux or on OS X, et cetera. And yeah, so you see full support. If I go back to Python environment, I could switch to another Python version for this project.
14:04
I could go and look at the packages installed. Oh, let me go back to my environment, actually. And if there were some updates for these packages, it would show up here. And I can just click on the packages and update the dependencies. So I don't have to. Yes, I could, of course, go on the command line,
14:22
do the same thing. But it is all supported by your IDE and IntelliSense. We will see what it is. But if you know Visual Studio already, you know everything about IntelliSense. Let me switch back to the slides so I don't forget. Anything? Probably not. OK, we can just go and look at this template.
14:44
If I go back to my solution and click on requirements, you see that the only requirements was Flask. Of course, Flask has a number of dependencies itself. And this is what got installed for me. OK, let's go and look at packages again.
15:04
I want to show you that you can also search PyPy directly into the IDE. For example, let's look for Django. Oh, sorry. No, no way. OK. So I can PP start for PyPy.
15:22
If I click here, it will just install Django for me into my virtual environment. So even for looking up into PyPy, I don't have to leave Visual Studio. I can do that directly within the IDE. OK, let's look at the code now. Which is probably more interesting.
15:40
RunServer.py is a default launch script created by the template. And as you can see, if you know, Flask is very pretty standard code here. And what I want to show you is that in Visual Studio, you are used to IntelliSense, which is basically code completion.
16:01
And you get that in Visual Studio as well. For example, if I go here and import. I don't know why I can't switch. I don't know. Anyway, you see that I get the menu with the option.
16:21
I don't know. Let's import random, for example. And then A equal. Oh, this is horrible. Sorry about that. I don't know what's happening. I can't switch it off. Yes?
16:44
Oh, it's going to take too long here. Let's just... Thank you, Randy. As you can see, I have IntelliSense, basically. Auto-completion. How does it work since Python is a dynamic language and Visual Studio usually works on compiled languages? Well, basically, and this is why I didn't install the project myself.
17:03
I switched to the already installed one because when it downloads the PIP packages, it goes and scans them, builds a cache of the system, and then at that point, it knows everything about the packages and it can offer IntelliSense for you. So when you install the first time,
17:21
it will probably take a while before IntelliSense picks up because it has to actually build a cache about your system and every cache is specific for the environment. And so, of course, when you create a new project, you can use an old environment and in that case, it won't rescan all the environment.
17:44
But this is a very nice method to get full code completion within Visual Studio for Python. Sorry, this is a random, so like this. Or maybe not. Now with this caps lock on,
18:01
it's going to be a huge problem. Sorry about that. Oh, my God. Okay, this is nice.
18:20
Not really. Okay, if I manage to get out of this trap, okay, maybe it is starting to work again, no?
18:53
Old style fixing. Let's see if this, no. Oh, my God.
19:01
Okay, we are in trouble, guys. Sorry, I don't know how to fix this. If anybody can help me, it would be appreciated. Oh, my God, really? I should turn it off. It usually works, that's true. With Witterbox, that's a good fix.
19:20
But it is going to take a while. Let's try that. That's Witterbox for you guys. Maybe just logging out might do the trick, but I will just restart it and we are going to waste a lot of time.
19:46
Restart. Luckily, we have the slides. Let's go back to the slides because they are on Mac. So let's go back here. We will get back to the demo once it has restarted. We talked about IntelliSense already.
20:01
And also, and hopefully I can show you, there is support for unit testing within Visual Studio, which is super nice. If you already use unit testing with C Sharp, you can use exactly the same interface and UI for testing in Python. So you have unit test support, the pytest support,
20:20
whatever you want to do with unit testing, you can do that with Python. And there is also, and this is super powerful, because one reason why Visual Studio is really appreciated around the world is because of its very powerful debugging tools. And the good news is that debugging in Python in Visual Studio is exactly the same experience you get with C Sharp and F Sharp
20:42
and whatever else Visual Studio supports, which means you can set breakpoints, you can inspect local variables, you can change the code as you write and see what happens and stuff like that. And also, it supports remote debugging before you ask. There is a nice article I have available here.
21:02
If you Google it up, this is Debugging Python Code on Linux. You just Google for Python Tools for Visual Studio Remote Debugging. And here there is a very nice YouTube video on how to debug a Linux server attaching from a Visual Studio, of course, a Python app on a remote server on Linux.
21:24
So you get really cool options here. Oh, look. Like, we might try again. And there is support for source control. This is not an option actually of
21:41
Python Tools, but Visual Studio itself supports source control, so you can use Git and all the features from Git within the IDE as well. Hopefully I can show you in a few minutes. And in that half demo that we saw before, we created a new project
22:01
starting from a template. But what if I want to import, to use code which is already existing somewhere, for example, on GitHub or in some remote repository on our local folder. You can do that. There is an import wizard. The reason you need an import wizard is because Visual Studio needs to build its own, let's call it, solution file.
22:21
For people coming from C Sharp, they know exactly what I mean. So it will create an additional file in your folder, which is a PI, PRJ, I believe, file, which is basically a solution file for Python. You can add it to your version control and check it out and commit it so people sharing your code
22:40
don't have to reimport the code the next time. I will show you if we have time. And yes, I also want to show you an import. Let's see at which point we are here. How many minutes do we have, Stefan? We have how many?
23:05
Oh, great. I can even drink some water. Okay, let's give it another shot. Now, Visual Studio is slow at starting up, so it doesn't help you.
23:22
Your Python. Also, I am within a VirtualBox machine. Of course, if you do this on a native Windows machine, it's going to be way faster.
23:41
So don't get sad because I'm slow here. It's kind of wanted. So what I wanted to do is show you some features. For example, what can we start with? Let's say that we launch this application. So this is a typical Flask application. I am not going to show you how Flask works, of course.
24:03
I just want to show you that we have a folder here. We have some HTML templates. We have a view.pi file here. As you can see, you're familiar with Flask. You have some routes, and here you see something,
24:20
a function called when the homepage is hit by the browser, et cetera. Now, let's try and launch this app. As you can see, I just use the usual Visual Studio stuff here. It will launch a command line, and then it should probably open the browser.
24:43
Yes, it takes a while the first time. Then it becomes faster. As you can see, the local host has been running. In this case, Microsoft Edge has been launched on the port, and here it is our website, which is running, of course, on Python from within Visual Studio.
25:01
Now, if you go back to the source code, we can go to the run server API, for example. Run server file, maybe. What is this? Okay. Let's stop the program,
25:23
go back to the layout HTML file, which is basically the master page for HTML page, and let's, for example, change. Again, because you get IntelliSense support. Oh, by the way, I'm trying.
25:40
Let's see if it works. I'm using Vim here, as you can see. I type the CT and the space, and I can. This is very interesting. If you come from Bash or Linux and are used to Vim, you don't have to change your habits. I mean, once you get into Vim, you can't get away from it.
26:03
I don't know if you share my experience, but once you have that muscle memory, you are doomed, basically. You can't do without Vim. So basically, I pick my editor, so based on the emulation of Vim, and it is good enough, I can use it. It is not good enough, I can't use it. Very simple. Probably you have the same experience.
26:22
So Vim is super cool, but do know that you are going to get addicted to it and you can't get away from it. It's just too powerful to be true. This one? No? Oh, let's just go with this and relaunch.
26:45
Oh, let's also do something else. Let's go back to the Views page. We saw we have an About page, just to speed it up. Here we have the route for the About page. Let's say that we want to pass a new value in this page. This is the Jinja template HTML, as you can see,
27:02
with Jinja support here. And again, it's not really relevant to what we are doing here. What I want to do is show you that we have support for something like this. Let's call this variable, I don't know, AeroPython.
27:21
And then let's go back to the controller and add a new value to the tuple here and say that AeroPython equals... Oh, sorry, I'm using... Oh, nice.
27:41
Hello. So basically, I'm adding a new value to the page. Yes? Really?
28:02
Here? Let me go back to the title tag. Oh, right. Let me go back and just do this. Okay. Let's see what we managed to crash or to break.
28:31
You should never do demos while speaking, but I can't resist the urge to do that. I mean, it's boring if you don't do demos, right?
28:41
As a programmer, I want to see code, live coding. So here it is. Ah, yes, the title changed. This didn't change because I undid the feature. Let's see the About page. As you can see here, we have this Hello message that we just changed.
29:02
Just to show you that this is just regular Python, but the nice thing is that we are in Windows within Visual Studio as we were doing C Sharp or whatever. Okay, let's go and look at this. I have this game I wrote with my... I would like to say that my daughter wrote,
29:23
but actually we wrote it together. It's a very simple Python game, guess the number. So it is on GitHub. I want it to use it in Visual Studio, clone it and work on it. So let's go copy the link back into Windows.
29:41
By the way, another very nice feature of Windows lately is Bash support for Windows. So basically you can go and use your Bash within Windows and this installs Ubuntu within Windows. As you can see now, I'm going to the Windows file system,
30:05
but I could use the Linux file system. Here I have a number of folders. Let's just git clone our... Let's see. No way.
30:30
No luck today. There is a marking going on, yes.
30:43
Yes, thank you. Now hopefully we can download this stuff. It's a very simple script. It should be fast.
31:05
While it clones, let's go back and look at, for example, adding some tests to our application here. So I go to my project, add...
31:20
Let me stop it. Add a new item. I should also have a Python unit test, as you can see here. What it does, it adds again a template file,
31:41
which has a basic test. Now if I open the Text Explorer within Visual Studio. As you can see, it is working up here. It's trying to understand what's going on. It should show our test in a few minutes, maybe in a few seconds. Of course, this is a failing test.
32:03
Here it is. If I run all my tests, it should probably fail. As you can see, if I go here and look at... This low resolution is killing me. Test failed, not implemented,
32:22
but we can go and do something about that. Let's try to fix this test. Let's move this code up here, or as you know, it won't be seen. Not really. Okay, something like this.
32:42
And then let's assume that... Okay, thank you. Let's say from run server. As you can see, Telesense again going on. Import host and port. For example, let's self-assert true
33:09
that host equals localhost, maybe. And that port equals 555.
33:21
It should be 555. I'm not sure. Let's try. Test passed, as you can see. Whoa. Victory. Okay. So as you can see, testing is exactly as you would do testing on Linux machine, but within the...
33:41
Again, the idea of a visual studio. And if I go back to my launch script and I put a break point here and launch my app, it should stop when it hits my break point.
34:01
Let me open the lockers and fix it. It's too big, maybe. Okay, as you can see, we hit the app.run instruction here, this line.
34:22
I can go and inspect the values directly by hovering the mouse over the application, inspect its values. And if I go here, I can look at all the local value. I can inspect every single value here, go deep into the tree and do all the usual stuff I do within Python, for example, or other powerful ideas.
34:42
This is super nice. If you do debugging, you can even set conditions here, like, for example, again, I have to reach this one, like, for example, host equals, I don't know, local host.
35:05
And so it will only break if this condition is true, et cetera. So as you can see, full support for debugging and for unit testing within Visual Studio. Let's go back and see what happened to our clone. Okay, it's done. So let's go back to Visual Studio again.
35:25
File, maybe new project. Let's first stop this one. New project. This time, we want to import from existing code.
35:40
As you can see, you have the option here. Don't do this, because it won't work yet. Add social control. It won't work that way. But if you go here, you just do new and import.
36:02
Wizard opens. You pick your project. It should be somewhere, code folder, guess. You just pick the folder. And again, since it is a Python project,
36:21
it wants to know which kind of interpreter do you want to use. Do you want to use the global one, or do you want to create a virtual environment? And which one is the launch script for this project? As you can see, detect virtual environment here.
36:41
And this is the file I mentioned before. Basically, what name do you want to give to the solution file for this project? And then you hit finish. And this will probably come up in a few seconds. Here it is. As you can see, we have our guess.pi file here.
37:00
Let me close the test file. This is a very simple game. Let's launch it. So what is your name, Nicola?
37:21
So we have to pick a number between 1 and 20. Now, since we are programmer, which number should we pick here? 11? Anybody else? 11 is good. Maybe 10? Might be better.
37:40
Your guess is too low. 11 was better. Let's do a 15. Too high. So let's do maybe what? 11. No, I don't want to do 11 because maybe it wins. OK, let's try. Too low. Told you.
38:01
So let's do 13. Ah, shit, it was 14. OK. I just had five guesses. So we won just by a split minute. OK, the whole point of this was to show you that you can use, of course, the user code. Now, if you go back to the folder here,
38:21
there are some files like the... Sorry, let me go within the directory. And by the way, using Bash, as you can see, OK, the colors are horrible, but don't mind that. And as you can see, there is a license file, a readme file, that was cloned from GitHub, and they don't show up in Visual Studio,
38:41
but we can simply go here, add existing item, pick them up, all files, license. This is because they need to go into the Python project file for Visual Studio.
39:00
So as you can see, they are here now. We probably don't have time to give a look at source control, but I could go now, I commit these changes, so the Python project for Visual Studio will contain these files the next time they are shown within my solution without any problem. As you can see here, we have our Git situation,
39:24
and I can go and commit the stuff and push it back to GitHub, to my remote, et cetera. Let me switch back. I believe we are almost done, right? Okay. So we played a game, we won.
39:40
Of course, you have a Python shell within Visual Studio, which is probably the most interesting of this talk, because if you go to Python environments here and open an interactive window, depending on the environment that you click here, now we don't have a virtual environment because we are in a, let's go back to 3.5
40:01
and open an interactive window. Where is it? Here. Okay, it works.
40:22
So you can do whatever you want within. You don't have to go to the command line, I mean. You can use the shell within Visual Studio for testing your own code. And you can even, from, I guess, it doesn't work, but it should. If we were in the server application we saw earlier,
40:40
I could import from our server, import my own function, and test it here right away. So it is super powerful. And there is also, let's go back to the slides, there is also support for IPython. So if you fancy that, you should. You can use IPython within Visual Studio as well.
41:01
And yes, so basically, as you can see, my two worlds, the Windows world, Visual Studio, C Sharp stack, and the Python world with VIM, and GitHub clones, command line, Bash, are finally kind of converging, which is super exciting for me.
41:22
Also because we are just starting. We are starting right now. It's a new project. It's been around for a couple of years, but there is still a lot to be done. You can already use it in production. And there are a few references here. I'm going to upload these slides on my, I will tweet the link to the website,
41:42
so you can, with the EuroPython tag, so you can get them. So there is a very nice YouTube section with demos from Steve Dower himself. There is a documentation site, et cetera. Go up, if you are interested, and look it up. Here are my handles, if you want to get in touch
42:01
or ask questions, et cetera. Thank you very much. And sorry for the crash, but we got it out of it, so it's good. No, but thank you for your talk, Steve. You are there. If you want to, if you have some question to Steve
42:21
and, of course, Nicolas about User Studio, it's no, it's time. No, no, you can do it. Thank you very much for the talk. You're welcome. I also have these words colliding sometimes because I'm a Linux developer
42:40
who works in a cross-platform team on Windows and the only slight problem that I still have with the Python tools is that I like to write tests in pytest style and the test explorer only recognizes traditional unit tests.
43:00
Do you know if there's any plans to also include pytest? Actually, I believe that pytest is already supported by Python tools. I spoke to Steve about a while ago and it mentioned that he was working on it. It should be already doable, actually, but I'm not sure. I can look it up and if you tweet me or send me an email, I will let you know. I believe it should already work.
43:21
I saw a guy playing with it at PyCon Italy and he was telling me that actually it's already supported. You can do pytest from within User Studio. So I'm not 100 percent sure, but if it isn't working, it will work real soon. Alright, thank you. You're welcome. Thanks for the demonstration.
43:41
One question. Can Visual Studio produce an installer that would install the whole project, including the dependencies, on a machine that has no live internet connection in Windows? Actually, no. This is the bad news. Not yet, by the way. So you still have to go back to the command line for doing that,
44:01
but again, we're just getting started, so probably it's going to happen soon enough. Thank you. Hi, Incola. I have another question. I saw that you could choose different Python versions when you build a virtual environment.
44:20
Did you install it before the Python versions? Yeah, so when I installed the Python tool for Visual Studio, which, by the way, works this way only if you are on Visual Studio 2017, if you are on Visual Studio 2015, you can get the extension, the Python tools for Visual Studio extension, but you need to install it as an extension, basically.
44:43
It doesn't come within the installation experience itself. It's an extension, basically. Yes, when I installed this, I already had a few Python installed here, and it will simply pick them up and show you them in the list. And again, you can choose to install new Pythons
45:01
from the installer itself in Visual Studio, or you can install them from the command line or with the classic install application, and Visual Studio will pick them up later on. Who has another question? No? Thank you, Incola. Okay, thank you again.