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