Python for the .NET Developer Transcripts
Chapter: The Python Language
Lecture: Language features we will cover

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Before we get into the details let's just briefly look at the various language features of Python
0:06 that we're going to cover, and how those map back to C#. We're going to start by talking about the language structure itself
0:13 what holds the language together and defines its elements. And in C# we have things like curly braces, and semicolons. Python has neither of those.
0:24 So, how do you define, like, an if statement or a function or a class, stuff like that? So this is what we're going to start focusing on.
0:31 Then I want to cover loops. C# and Python have a lot of similarities but there's also a few unique and powerful features to loops
0:39 in Python that we want to look at, because they're not obvious until you've had some time to work with the language and they're really powerful.
0:46 Functions, functions are first class objects in Python similar to C#, but C#, all functions have to be contained within a class.
0:54 Python, not so much, so they're a little more flexible in that regard. Generators, lazy functions, things that use the yield return
1:03 keyword in C#, or maybe the LINQ extension methods like Where and Select and so on. You'll see that Python has something like this as well
1:12 these great functions that are super easy to turn into iterators or generators so we're going to definitely talk about that.
1:19 Ternary conditional expressions, delegates some of the terminology I'm using here is C# terminology but that's not what they're called in Python.
1:27 But since you are C# developers I'm going to speak your language as much as possible when we get started here.
1:33 How do we define a function that can be passed as an argument or accepted as an argument? Some of the best delegates are lambda expressions
1:40 these short little functions that you can pass along without going to all the trouble to create separate functions.
1:46 See, Python has great support for those as well. Closures, when a function captures data and holds onto it for the lifetime of that function
1:54 which is pretty interesting. Type systems and runtime types think of Python as a dynamic language but actually all the runtime elements do have types
2:04 and there's actually some static typing that we can use in the language. Error handling and exceptions, a lot of similarities here.
2:11 Using blocks, the idea of for this little block of code, even within a function just a smaller block to find it
2:18 using context where code is going to run and then outside of that something important's going to happen.
2:23 A file's going to be closed, transaction will be rolled back something like that. We'll see how we work with these types of constructs
2:30 IDisposable, and so on, in Python. Finally, the switch statement. Python itself doesn't have a switch statement
2:37 but because it's a very flexible language there's some really cool things we can make, like almost like language switch statements.
2:43 So, you'll see you can do some really interesting things there. Now if you look at this list, these are a lot of the things
2:49 that you probably think, oh, these are really important to me in C# and every one of them has a great implementation in Python.
2:57 See something missing there? What about classes? Do we have classes in here? No. Don't worry. Python, of course, has classes
3:06 in object oriented programming, and all that kind of stuff. Because it is important, we're going to treat that as its own separate chapter.
3:12 So we're going to over the idea of classes here but that's not because they don't exist that's because we're actually treating them
3:18 with a little extra love and care later.

Talk Python's Mastodon Michael Kennedy's Mastodon