Latest / CyberSecurity Summary / Visual Studio Code for Python Programmers
Transcript
- 0:00Speaker 1: Welcome to the Deep Dive. We're the show that helps
- 0:02Speaker 1: you navigate complex topics, giving you that essential clear view
- 0:05Speaker 1: from the.
- 0:05Speaker 2: Summit, and today we're looking at something many Python developers
- 0:09Speaker 2: grapple with, moving beyond basic tools like idl E.
- 0:13Speaker 1: Exactly, you hit a point where those simpler environments just
- 0:17Speaker 1: well they create friction right to slow you down.
- 0:19Speaker 2: I absolutely do so. Our deep Dive today is focused
- 0:22Speaker 2: squarely on Visual Studio Code or VS code. We've really
- 0:26Speaker 2: dug into resources like Visual Studio Code for Python programmers
- 0:30Speaker 2: to understand how it's specifically built for an efficient, productive Python.
- 0:33Speaker 1: Workflow, and our mission for you listening in is straightforward.
- 0:37Speaker 1: We want to give you a clear path through the
- 0:39Speaker 1: essential vs code features for Python. Think set up coding faster, debugging, smarter,
- 0:45Speaker 1: even collaborating.
- 0:46Speaker 2: Yeah, basically shortcutting your way to getting really comfortable and
- 0:48Speaker 2: effective with this editor.
- 0:49Speaker 1: Okay, so where do we start The foundation seems right.
- 0:53Speaker 2: Definitely, let's kick things off with just getting the environment
- 0:56Speaker 2: set up correctly.
- 0:57Speaker 1: First impressions of VS code, the UI. It looks simple,
- 1:02Speaker 1: almost sparse sometimes.
- 1:04Speaker 2: And that's deliberate. The whole philosophy is keeping your focus
- 1:07Speaker 2: on the code like ninety percent of the screen real estate.
- 1:10Speaker 2: That's for your source code.
- 1:11Speaker 1: You've got the activity bar, sidebar panels, status bar, but
- 1:16Speaker 1: they don't dominate.
- 1:17Speaker 2: Exactly the code is king. But here's the critical thing,
- 1:20Speaker 2: what we might call the.
- 1:22Speaker 1: Extension crux a right. VS code itself only really knows
- 1:26Speaker 1: web language is out of the box, JavaScript, HTML, that
- 1:29Speaker 1: sort of thing.
- 1:29Speaker 2: Precisely for Python development, you are entirely dependent on installing
- 1:33Speaker 2: the official Python extension from Microsoft.
- 1:35Speaker 1: So without that extension, yep, no proper Python support.
- 1:39Speaker 2: Nope, no advanced syntax highlighting, no intelligent code completion, and
- 1:44Speaker 2: crucially no debugging capabilities for Python. It's non negotiable.
- 1:48Speaker 1: You have to install it, okay, extension first, but even
- 1:51Speaker 1: before that you obviously need Python itself.
- 1:54Speaker 2: Installed correct, and the recommendation is Python three point six
- 1:57Speaker 2: or newer.
- 1:58Speaker 1: And a quick tip here, especially for Windows users that
- 2:01Speaker 1: add Python to path checkbox during installation.
- 2:04Speaker 2: Oh, absolutely check that box. Please check that box. Save
- 2:06Speaker 2: so much Hasselator does countless headaches avoided. Seriously. So, once
- 2:11Speaker 2: Python's installed, VS code is pretty good at finding it.
- 2:14Speaker 1: Where do you look to manage that?
- 2:16Speaker 2: The status bar bottom of the window, it'll show the
- 2:19Speaker 2: Python version you're currently using for that project, or it'll
- 2:22Speaker 2: prompt you to select one if it hasn't found one yet.
- 2:24Speaker 1: And when you click that, it shows you everything pretty much.
- 2:28Speaker 2: Global installs, virtual environments, conda environments, whatever it detects on
- 2:33Speaker 2: your system. It lists them so you can pick the
- 2:35Speaker 2: right path for.
- 2:36Speaker 1: Your workspace, which leads us nicely to the next absolutely
- 2:39Speaker 1: essential practice. Isolation.
- 2:42Speaker 2: Yes, cannot stress this enough. Always always use isolated environments,
- 2:47Speaker 2: virtual environments, conda environments, whatever your preference.
- 2:49Speaker 1: Why is that so critical?
- 2:50Speaker 2: Dependency conflicts? Project A needs library X version one point zero,
- 2:54Speaker 2: Project D needs library ex version two point five. If
- 2:56Speaker 2: you install everything globally, boom, things break horribly exactly. Isolation
- 3:03Speaker 2: keeps each project's dependency separate and manageable, and vs code
- 3:07Speaker 2: helps here too. It automatically detects when you create a
- 3:10Speaker 2: new virtual environment within your project folder and prompts you, hey,
- 3:13Speaker 2: found a new environment, want to use it for this workspace?
- 3:16Speaker 1: That's andy, takes away some of the manual.
- 3:18Speaker 2: Steps, makes it easier to do the right thing, which
- 3:20Speaker 2: is always good.
- 3:20Speaker 1: Okay, foundation laid, Python installed extension, active environment, isolated. Now
- 3:26Speaker 1: let's get into actually writing code faster. Part two productivity.
- 3:31Speaker 2: Leveraging that setup first up intell a Sense.
- 3:35Speaker 1: Microsoft's term for all the smart edding features.
- 3:37Speaker 2: Yeah, code completion, parameter info, quick info on hover, seeing
- 3:43Speaker 2: object definitions, all that stuff that saves you looking things
- 3:46Speaker 2: up constantly.
- 3:47Speaker 1: How do you trigger it? Just typing?
- 3:49Speaker 2: Often? Yes, Typing a dot after an object in Python
- 3:52Speaker 2: is a common trigger, or the classic stretrol plus space
- 3:55Speaker 2: bar usually brings up suggestions. It's like having reference stocks
- 3:58Speaker 2: right at your cursor keeps you in this low totally.
- 4:01Speaker 2: And this leads to I think our first real aha
- 4:04Speaker 2: moment for productivity, quick fixes and those intelligent imports. Uh.
- 4:08Speaker 1: The little light bulb I always likes seeing that means
- 4:11Speaker 1: help is on.
- 4:11Speaker 2: The way exactly. It pops up when vs code detects
- 4:15Speaker 2: something it might be able to fix for you. And
- 4:17Speaker 2: the Python Extensions ad imports quick fix is brilliant.
- 4:21Speaker 1: How does that work?
- 4:22Speaker 2: Say you type NP dot free because you're thinking NUMPI
- 4:27Speaker 2: or PD for pandas if you haven't imported them yet,
- 4:29Speaker 2: The light bulb appears, Click it and boom, it adds
- 4:33Speaker 2: important NUMPI as NP or import pandas as PD at
- 4:37Speaker 2: the top of your file for you.
- 4:38Speaker 1: Oh, that's nice. It knows the common abbreviations TF for
- 4:41Speaker 1: TensorFlow too.
- 4:42Speaker 2: Yeah, it handles the standard ones for major packages. Really
- 4:46Speaker 2: speeds up data science work for example.
- 4:48Speaker 1: Okay, but there was a catch to getting that really
- 4:50Speaker 1: slick import behavior. Wasn't there something about the language server?
- 4:53Speaker 2: Ah you remembered, Yes, good point. To get this specific, faster,
- 4:57Speaker 2: more intelligent behavior, including those quick imp you generally need
- 5:01Speaker 2: to switch away from the default Jedi language.
- 5:03Speaker 1: Server, right, You need to use the Microsoft Python language
- 5:06Speaker 1: server instead.
- 5:07Speaker 2: Correct, And that means going into your settings dot json
- 5:10Speaker 2: file and adding the line python dot jetti enabled dot false.
- 5:14Speaker 1: So slip a switch in the settings for better performance
- 5:16Speaker 1: and features.
- 5:17Speaker 2: Basically, yeah, it's a trade off you make to get
- 5:19Speaker 2: the enhanced experience worth doing in my opinion.
- 5:22Speaker 1: Okay, noted, So code is working, imports are fast. What
- 5:26Speaker 1: about making it clean, readable, maintainable?
- 5:31Speaker 2: Formatters and linters absolutely essential, especially in teams. Let's start
- 5:36Speaker 2: with formatters. Their job is purely about code style, consistency.
- 5:40Speaker 1: Making sure everyone's code looks the same, spaces, line breaks, quotes.
- 5:45Speaker 2: That's stuff exactly that It reduces cognitive load when reading code,
- 5:49Speaker 2: and maybe more importantly, it cuts down massively on merge
- 5:53Speaker 2: conflicts caused by trivial whitespace changes.
- 5:56Speaker 1: What are the main options? Vis code supports.
- 5:58Speaker 2: Three big ones. Autopep is the default. Its goal is
- 6:01Speaker 2: simply to make your code conform to the PEP.
- 6:03Speaker 1: Eight style guide, the official standard. Right.
- 6:05Speaker 2: Then you have Black. Black is opinionated, it's deliberately not
- 6:09Speaker 2: very configurable.
- 6:09Speaker 1: Sounds restrictive.
- 6:10Speaker 2: It is, but that's its selling point. If everyone on
- 6:12Speaker 2: the team uses Black style debates, just vanish. The code
- 6:16Speaker 2: will look the same period.
- 6:18Speaker 1: H in force consistency. I can see the appeal.
- 6:20Speaker 2: And the third is YAPF, yet another Python formatter from Google,
- 6:24Speaker 2: which is also opinionated, but maybe offers a bit more
- 6:27Speaker 2: configuration than Black. Choosing one is really a team or
- 6:31Speaker 2: project decision.
- 6:32Speaker 1: Okay, so formatters handle the Look what about linters? They
- 6:35Speaker 1: do mores right, they do.
- 6:37Speaker 2: Linters analyze your code for potential errors, style guide violations
- 6:42Speaker 2: beyond just formatting, and even bad coding practices or potential bugs.
- 6:46Speaker 1: They're like automated code reviewers kind of.
- 6:49Speaker 2: Yeah. The default is pilont. It's very comprehensive, checks for
- 6:52Speaker 2: errors and forces coding standards, looks for code smells.
- 6:55Speaker 1: What else is common?
- 6:56Speaker 2: Flake eight is popular. It combines a few other tools
- 6:59Speaker 2: and focuses heavily on PP eight compliance and logical errors.
- 7:02Speaker 2: And then there's bandit.
- 7:03Speaker 1: Band it sounds interesting.
- 7:05Speaker 2: It is. Ban It specifically looks for common security vulnerabilities
- 7:09Speaker 2: in your code, things like potential SQL injection, risks, hard
- 7:13Speaker 2: coded passwords, unsafe library usage. Really important if your code
- 7:18Speaker 2: handles sensitive data or runs.
- 7:19Speaker 1: In production and these aren't automatically yep.
- 7:22Speaker 2: Typically linting happens every time you save the file. You
- 7:24Speaker 2: get immediate feedback via squiggly lines and the problems panel.
- 7:28Speaker 1: Nice and quickly. What about refactoring cleaning up codes?
- 7:32Speaker 2: Structure vs Code has built in commands for that too,
- 7:35Speaker 2: things like extract variable or extract method to help you
- 7:39Speaker 2: break down complex functions.
- 7:41Speaker 1: Oh, that's useful.
- 7:43Speaker 2: And sort imports, which uses the ice Wort library behind
- 7:46Speaker 2: the scenes to automatically organize your import statements alphabetically and
- 7:50Speaker 2: group them again, great for consistency and readability. Plus snippets
- 7:55Speaker 2: for boilerplate code.
- 7:56Speaker 1: Okay, that covers a lot of ground for writing and
- 7:58Speaker 1: cleaning code. Shift gears Part three Advanced workflows Debugging has
- 8:05Speaker 1: to be top of the list.
- 8:06Speaker 2: Absolutely, Moving beyond just sticking print statements everywhere.
- 8:09Speaker 1: That's inefficient and missy and often doesn't tell you the
- 8:12Speaker 1: whole story exactly.
- 8:14Speaker 2: The core debugging concept in VS code, like most idase,
- 8:17Speaker 2: is the breakpoint, that little red dot you click in
- 8:19Speaker 2: the margin next.
- 8:20Speaker 1: To a line number, and that just pauses the program.
- 8:22Speaker 2: Instantly halts execution right before that line runs. Then you
- 8:25Speaker 2: can inspect everything variable values, the call stack, showing how
- 8:28Speaker 2: you got there, Step through the code line by line.
- 8:31Speaker 1: What are the main ways to step?
- 8:32Speaker 2: You've got the standard controls continue, run until the next breakpoint,
- 8:37Speaker 2: step over, run the current line, but step over function
- 8:40Speaker 2: calls without going inside. Step in two, go inside the
- 8:43Speaker 2: next function call, step out, finish the current function, and
- 8:45Speaker 2: return to the caller, plus restart and stop.
- 8:49Speaker 1: Pretty standard debugger controls. But the sources mentioned some specific
- 8:53Speaker 1: VS code features that sound like game changers. Log points.
- 8:57Speaker 2: Ah Yes, log points. This is our second aha moment.
- 9:01Speaker 2: I think they are genuinely transformative for certain debugging scenarios.
- 9:06Speaker 1: How do they differ from breakpoints? They look like a diamond,
- 9:08Speaker 1: not a dot.
- 9:09Speaker 2: Right, A breakpoint stops execution, a log point does not. Instead,
- 9:13Speaker 2: when the program hits a log point, it just outputs
- 9:15Speaker 2: a message to the debug console and keeps running.
- 9:17Speaker 1: So like a print statement, but without modifying the code exactly.
- 9:21Speaker 2: Imagine you have a long running process, maybe something in
- 9:23Speaker 2: a loop, and you want to track how a variable
- 9:25Speaker 2: changes over time. But you don't want to stop the
- 9:28Speaker 2: program every single iteration or clutter your.
- 9:30Speaker 1: Code with temporary prints, you have to remember to remove precisely.
- 9:34Speaker 2: With a log point, you write click in the margin,
- 9:36Speaker 2: choose ad log point, and type a message. You can
- 9:39Speaker 2: even include variable values directly in the message using curly
- 9:42Speaker 2: braces like current value my variable.
- 9:45Speaker 1: Oh wow, so you can monitor state without halting anything.
- 9:48Speaker 1: That's really powerful.
- 9:50Speaker 2: It's fantastic for diagnosing issues in complex loops, asynchronous code,
- 9:54Speaker 2: or anywhere you need to observe behavior over time without
- 9:57Speaker 2: constant interruption.
- 9:58Speaker 1: Okay, log points for NonStop monitoring. What about making break
- 10:01Speaker 1: points smarter? Conditional breakpoint?
- 10:05Speaker 2: Yes, this is about adding precision. Sometimes a line of
- 10:08Speaker 2: code gets hit thousands of times in a loop, but
- 10:11Speaker 2: you only care about the one time when a specific
- 10:13Speaker 2: condition is met.
- 10:14Speaker 1: Like maybe a bug only happens when a counter variable
- 10:16Speaker 1: reaches one thousand.
- 10:17Speaker 2: Exactly, or maybe when a specific user ID say studentit
- 10:21Speaker 2: equals zero zero zero three is being processed. Instead of
- 10:25Speaker 2: setting a normal breakpoint and hitting continue nine hundred and
- 10:28Speaker 2: ninety nine times, you set a conditional one.
- 10:30Speaker 1: Well, how do you set the condition?
- 10:31Speaker 2: Right click the breakpoint, choose edit breakpoint, and enter an expression.
- 10:36Speaker 2: It can be based on hunt, hitcount ten, or any
- 10:39Speaker 2: Python expression that evaluates to true or false. Varioblex some value.
- 10:44Speaker 2: End status equals error.
- 10:46Speaker 1: So the debugger only pauses if that condition is true
- 10:49Speaker 1: when the line is reached precisely.
- 10:51Speaker 2: Surgical debugging saves an immense amount of time.
- 10:54Speaker 1: Okay, so we're paused either at a normal breakpoint or
- 10:57Speaker 1: a fancy conditional one. What's the debug console? You make?
- 11:00Speaker 2: Ah, the debug console. It's essentially a RPL a read
- 11:05Speaker 2: evil print loop, but it's connected directly to your paused
- 11:09Speaker 2: program's current state.
- 11:10Speaker 1: So I can type Python code in there, yes.
- 11:12Speaker 2: And it executes within the context of where your program
- 11:15Speaker 2: is paused. You can inspect variable values just by typing
- 11:18Speaker 2: their names. You can call functions that are available in
- 11:20Speaker 2: that scope.
- 11:21Speaker 1: And the real power you mentioned was changing things.
- 11:24Speaker 2: That's the killer feature. Let's say you're paused and you
- 11:26Speaker 2: inspect a variable, maybe a dictionary, and realize it's missing
- 11:30Speaker 2: a key or has the wrong value.
- 11:32Speaker 1: Which is causing the bug further down right.
- 11:34Speaker 2: Normally, you'd have to stop debugging, go edit the source code,
- 11:38Speaker 2: restart the whole application. Get back to that point could take.
- 11:41Speaker 1: Ages, especially with complex setups.
- 11:43Speaker 2: But with a debug console RPL, while paused, you can
- 11:46Speaker 2: just type code to fix the variable right there, like
- 11:49Speaker 2: mighty missing key all gize some value or counter zero.
- 11:53Speaker 1: You modify the program state live while.
- 11:55Speaker 2: It's paused exactly. You apply the potential fix, and the
- 11:58Speaker 2: RPL then hit Can you if the program now runs
- 12:02Speaker 2: correctly past the point where it previously failed. You've just
- 12:05Speaker 2: confirmed your fix without restarting anything.
- 12:07Speaker 1: That sounds incredibly efficient for testing fixes.
- 12:10Speaker 2: It transforms debugging from a slow edit run fail cycle
- 12:14Speaker 2: into an interactive troubleshooting session.
- 12:16Speaker 1: It's amazing, Okay, shifting from solo debugging to teamwork. Source
- 12:20Speaker 1: Control vs Code integrates with get pretty.
- 12:23Speaker 2: Tightly, very tightly, assumes you have GET installed version two
- 12:27Speaker 2: point zero or later. The source control view the little
- 12:30Speaker 2: branching icon constantly tracks your changes, so the.
- 12:32Speaker 1: U for untracked M for modified files.
- 12:35Speaker 2: Yeah, make staging, committing, viewing difts really straightforward.
- 12:38Speaker 1: Right within the editor and for get ub users, there's
- 12:41Speaker 1: that specific extension.
- 12:43Speaker 2: Oh yeah, the GitHub pull requests and issues extension. It's
- 12:46Speaker 2: almost essential if you live on GitHub. You can manage
- 12:49Speaker 2: pull requests, review code at comments, approve, merge, create issues,
- 12:54Speaker 2: all without leaving.
- 12:55Speaker 1: Vs Code automates a lot of the command line get dance.
- 12:58Speaker 2: It really does streamline the whole workflow.
- 13:00Speaker 1: And one more collaboration tool, Live Share. What's the idea there?
- 13:05Speaker 2: Think Google Docs, but for your entire coding environment.
- 13:08Speaker 1: Seriously.
- 13:09Speaker 2: Yeah, as a host, you can start a live share
- 13:12Speaker 2: session and send a link to guests. They join your
- 13:15Speaker 2: session right from their own vs code.
- 13:17Speaker 1: Instance, and they can see my code.
- 13:18Speaker 2: They can see your code, see your cursor moving, see
- 13:21Speaker 2: your edits in real time. You can grant them read
- 13:24Speaker 2: only access or full collaborative editing rights.
- 13:26Speaker 1: So we could literally type in the same file at
- 13:29Speaker 1: the same time you could.
- 13:30Speaker 2: You can also share your server reports so they could
- 13:32Speaker 2: interact with a web app you're running locally, and even
- 13:35Speaker 2: share a terminal session again read only or fully collaborative.
- 13:40Speaker 1: Wow, that's like remote pair programming on steroids.
- 13:43Speaker 2: It's incredibly powerful for mentoring, debugging together, or just collaborating closely.
- 13:49Speaker 2: When you're not physically in the same room.
- 13:51Speaker 1: Okay, so stepping back, we've covered a lot setting up
- 13:54Speaker 1: the foundation right with Python, the extension isolated environments.
- 13:58Speaker 2: Then boosting productivity within tellis us, smart imports, formatters.
- 14:02Speaker 1: Linters, and finally these really advanced workflows log points, conditional breakpoints,
- 14:08Speaker 1: the interactive to bug console r EPL, integrated GIT and
- 14:12Speaker 1: live share.
- 14:13Speaker 2: It really paints a picture of vs code as much
- 14:16Speaker 2: more than a text editor. It's a comprehensive toolkit for
- 14:18Speaker 2: Python development.
- 14:19Speaker 1: We saw just how powerful those debugging tools, log points
- 14:23Speaker 1: the RPL are for figuring out what's happening in a
- 14:25Speaker 1: script running on your own machine. But the source material
- 14:28Speaker 1: also highlighted vs code's reach into bigger environments containers Jupiter notebooks,
- 14:33Speaker 1: web frameworks like Flask and Jango, even deploying to cloud
- 14:37Speaker 1: platforms like Azuo functions.
- 14:39Speaker 2: That integration is key. It aims to provide a consistent
- 14:42Speaker 2: experience across different contexts.
- 14:44Speaker 1: So here's the final thought to chew on. Imagine using
- 14:47Speaker 1: those same sophisticated tools log points to monitor state without stopping,
- 14:52Speaker 1: conditional breakpoints to zero in on rare events, the debug
- 14:56Speaker 1: console r EPL to test fixes live okay, but you're
- 14:59Speaker 1: doing it not just on a local script, but on
- 15:01Speaker 1: code running inside a Docker container, or within a complex
- 15:04Speaker 1: Jupiter notebook, or even attached to a process running remotely
- 15:07Speaker 1: on a cloud service like Azure Functions, all from your
- 15:10Speaker 1: familiar editor interface.
- 15:12Speaker 2: Right, connecting that deep debugging power directly to these complex,
- 15:15Speaker 2: often remote production like environments.
- 15:18Speaker 1: What does that capability truly mean for your ability to
- 15:21Speaker 1: diagnose and squash bugs in those really challenging multi component
- 15:25Speaker 1: applications we often deal with today.
- 15:27Speaker 2: It drastically shrinks the feedback loop right produces the friction
- 15:30Speaker 2: of diagnosing problems in those complex systems.
- 15:33Speaker 1: Exactly. It bridges the gap between your powerful local editor
- 15:36Speaker 1: and the realities of modern deployment. So the question for
- 15:40Speaker 1: you is what complex, real world bug, maybe one that's
- 15:44Speaker 1: been nagging you, could you finally tackle if you brought
- 15:47Speaker 1: the full power of log points and the debug console
- 15:49Speaker 1: alreadypl to bear on.
- 15:50Speaker 2: It something to think about. It could save you a
- 15:53Speaker 2: lot of time and frustration. Thanks for diving deep with
- 15:56Speaker 2: us today.