Python for .NET Developers Transcripts
Chapter: The Python Language
Lecture: Intro to the C# code
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Well enough with that PowerPoint let's put that away and get our hands dirty and really start focusing on the code, and the editors
0:07
and creating some little applications. Little in the beginning, slightly bigger at the end. Before we get into the Python code, we're actually
0:15
going to talk about some C# code, because almost all the things, not everything, but most of what I'm going
0:21
to show you in Python we start out by looking at it in C# and then creating it in Python. So for each thing that we do in the course you're going to
0:29
have a nice analogy, here's what it was in C# here it is in Python, I can run and play with them both.
0:34
If we're over in the GitHub repository notice there's a net, .NET but doesn't work super well in all the systems
0:40
it would hide that directory for example. So just net is what I'm calling it right here and we have a Python section which is empty.
0:48
I'm going to mostly stick to working on macOS not because Python doesn't work over on Windows but because it's a little bit easier for me
0:57
and I'm going to give you a cleaner, better presentation of Python on macOS than I will on Windows just because that's where I work and all the hotkeys
1:06
are broken for me on Windows. I worked on Windows for many, many years but recently the hotkeys there have been erased
1:12
so, I'm going to just stay on macOS for the most part. We are going to do a little work with Windows 10 and APS.NET, at least in the beginning we're
1:21
going to be here on my Mac. Now, doesn't mean we can't do .NET, but we don't have Visual Studio for Mac which is pretty cool they have this these days.
1:29
We're going to work with the various programs. So this is the code that is already existing it's in the GitHub repository to start from
1:36
and we're going to look at it. We're going to look at this chapter three language here. We don't have code for chapters 1 and 2
1:44
because those were just intro things but I decided to match it up with the videos. Over here we've got this shape of code
1:51
so here's a simple, simple program that we're going to run and basically we've got a bunch of different things like here's for typing
1:59
here's for turning our expressions and so on and they each have a run method which I'm calling from program.
2:05
Yes, I could change the run configuration, the project about which one runs, but I find just always running this file
2:11
and just un-commenting and commenting out different parts of a program is what we're going to do. So we're going to run this shape of code
2:18
this should look familiar to you this should be very simple code. If you're a C# developer there's nothing fancy going on here.
2:24
So we have a run function, it prints out on a single line and asks you a question at the end of that line what is your name?
2:32
And then it just passes that off to some method, OK? So in this, the method here takes a string, a name
2:38
and it checks if the name is, if you need to lower it trim it and all that, you know, ignoring whitespace and capitilization. If it's Michael it says
2:47
Hello, old friend otherwise it says Nice to meet you and it's using this $ for string interpalation
2:53
to print that out, instead of format, which is pretty cool says My name is C#! Let's run it. So here it asks what is your name?
3:01
My name is Michael. Hello, old friend. We can run it again. My name is Bill. Nice to meet you, Bill, my name is C#!.
3:13
Very exciting, not super surprising to you, right? So, this is standard C# code we have a name space, we have a class
3:22
and then we have static or instance methods here's our static run, and then, obviously our other static method.
3:28
Our if statements have parenthesis around them and there's curly braces creating them. Obviously for if statements and one liners
3:35
that's not required, but in general it is and then all of our statements are terminated with semicolons, you should know this, right?
3:43
But this is very different than Python. Now we have type names here, right there's a type definition about the argument as a string
3:51
and it's return value is void, and so on.