Python for Absolute Beginners Transcripts
Chapter: The big ideas of software development
Lecture: Big idea: How does code execute?
0:00 How does code execute?
0:01 Well, we're going to focus of course on Python code
0:04 and one of the things I have to do a lot
0:07 I mean in a whole lot
0:08 more than is reasonable I think
0:10 is I need to take proper titles
0:13 and convert these to either file names or the folder names
0:16 as I'm developing these courses
0:18 working on my podcast and so on.
0:20 And that can be a little bit error prone.
0:22 For example, if I want to take the phrase
0:24 the title here How does a code execute?
0:26 That is not a valid thing
0:28 I can put as a url because the question mark means something
0:31 and these spaces aren't created
0:32 and the capital H is kind of a problem.
0:35 So a reasonable thing to do would be to
0:36 lower case everything
0:38 drop the punctuation
0:39 put dashes in between it
0:40 that will work for file systems stuff
0:42 like folders or even urls as you might guest by the name.
0:45 Because I want to make this something I want to think about
0:49 make it completely obvious and re-usable
0:51 and maybe even compose-able
0:52 I mixed it in with other scripts or something like that.
0:55 I wrote this program called urlfy
0:58 and the way we run it is we say python space urlfy.py
1:04 and this is going to take this source code
1:06 the Python code that I wrote in a file and then execute it.
1:10 Notice we have in the clipboard the title basically
1:13 How does this code excute or how this code execute.
1:15 When I run it, a little title thing
1:17 urlfy dash, dash, dash, dash comes out
1:19 and says we're reading data from the clipboard
1:21 so the program uses a library to access
1:24 the macOS clipboarder, really in a clipboard
1:27 and then it's just give you a null.
1:28 Okay, the thing we're going to turn into url format
1:31 is how does code execute question mark
1:33 and then it coverts it how to how doe code execute
1:35 with dashes and lower case
1:36 just like I described.
1:37 And because that was so fun
1:38 and you always want to have a little break and a shoot day
1:40 let's shoot out a few emojis
1:42 three stars and like a little triple star
1:44 farther in the distance.
1:46 And it's in the final message to the user
1:48 copied to the clipboard
1:49 and put a little emoji of a clipboarder
1:51 something like that so we can just type this line
1:54 and then whatever is in the clipboard
1:55 is now transformed into this form
1:57 that we can paste somewhere else.
1:59 So this is great.
2:00 This is super useful
2:01 and this is actually something
2:02 that is a great place to start
2:04 when you're learning Python.
2:05 'Cause this little tiny utilities
2:07 like you know what I do all day?
2:09 I've take this words
2:10 and I turned them into subs that is valid
2:12 to put in into folder names or file names.
2:14 Well, if you want
2:16 you can write a little program
2:17 so probably 15 lines to Python code
2:20 and it does this automatically
2:22 never making an error.
2:23 Super, super handy.
2:25 So the big question is
2:26 what is actually happening here?
2:28 Sure, once we understand the Python codings
2:31 they will run it at this line and this line and this line
2:33 but there is actually a whole lot on going on.
2:36 Right, there's RAM and CPU instruction
2:38 and all kind of interesting stuff happening.
2:41 So in this short section
2:42 we're going to focus on what happens
2:44 when we give Python some source codes
2:46 and it actually runs it as a program.