- Podcasts
- CyberSecurity Summary
- The Quick Python Book, Second Edition
About this episodeThis Book is from the second edition of The Quick Python Book, a programming tutorial. The book covers fundamental Python concepts…
You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary
Get the Book now from Amazon:
https://www.amazon.com/Quick-Python-Book-Second/dp/193518220X?&linkCode=ll1&tag=cvthunderx-20&linkId=538029833ee12fb4f98e07dc65708589&language=en_US&ref_=as_li_ss_tl
Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
The Quick Python Book, Second Edition
One thing that really jumped out at me was the emphasis on balance. Python. It's designed for readability, you know, without sacrificing the power you need to get things done. Sure, maybe it's not always the absolute fastest code, but what you get in return is a language that almost reads like plain English.
That's a great way to put it. The indentation thing is a perfect example. Yeah, in most languages you've got your curly braces, these blocks of code, but Python it just uses indentation. And what's interesting is it kind of forces you to write cleaner code really, because it has to be visually structured well for it to even work.
Think of a list, right, It's like your shopping list. You can add things, you can take things away, you can rearrange the orders. It's flexible, makes sense. But a tupple, on the other hand, that's fixed. It's more like a record of an event, like the date, the time, the location. That information doesn't get to change.
So remember how Python lets you pass arguments to functions in like a bunch of different ways. Oh yeah, you get your positional arguments, your keyword arguments right right. It gets kind of wild, it does. But those features, those flexible ways of working with functions, they were like heavily on tuples behind the scenes. That's what's going on.
It's well, imagine writing code that writes other code. Whoa, It's like it's like programming on steroids. Sounds intense, it is, But it lets you do things like, say you want to create classes dynamically based on what the user does, or even change how existing functions work without even touching the original code.
Perfect analogy. Yeah, the book really emphasizes this. How as your Python projects grow, you need to think about this organization. How do we use your code? Modules that are like those individual drawers. They hold related functions and classes and variables, you know, things that go together. And then the packages those are like the cabinets. They group related modules and then.
That, right, like getting the current directory, changing directories, building file paths. It's like having a GPS for your code exactly. And then there's reading and writing files, you know, that's how we actually interact with data that's stored on our hard drives. The book covers those core functions too, like open, read, write.
It's an interesting part of how Python actually works, right. I Mean, we all know about our dot pi files, that's our source code, but behind the scenes, Python's actually compiling those into dot pi files, okay, and those those contain bytcode, which is a lower level way to represent the code that the Python interpreter can run more efficiently.
Modify itself. That's the core of it. It's like whoam blurring the line between the code, yeah and the data, right? You know, because in Python everything an object, right, classes functions, they're all objects, and metaprogramming lets you lets you work with them like they're just data that you can change at runtime.
Can you give me like a concrete example of how that would be useful? Sure? Imagine you're building like a web framework, right, and you needed to find routes for handling different web requests. Okay, with metaprogramming, you could write a function that automatically generates those routes. Wow, based on you know, the functions you've already written in your application.
They are that they are a way to modify how a function works without actually changing the code of the function itself. Okay, so imagine you have a function, yeah that fetches data from a website, right, Okay, you could write a decor that adds cashing to it, so it only downloads the data once oh I see it, and the stores it for later. So next time you call the function, it's much faster.
