From the course: Building Tools with Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Ensuring functionality

Ensuring functionality - Python Tutorial

From the course: Building Tools with Python

Start my 1-month free trial

Ensuring functionality

- [Instructor] When we build something that will run in an environment different than our own, it's important to do some checking to make sure things are as we expect them to be. Here in Python, we can do that with a series of if statements or try accept statements to test for the things we assume will be present on the target system. If our script relies on an outside binary, for example, we can check for it, and if it doesn't exist, we can let the user know specifically that fact or just that some required software isn't available and that they should contact whoever supports the software to fix it. We can also take this approach to make sure that files or folders we need to write information to are writeable or even the particular modules are available before we go to try and use them. In a Python app, you might consider importing modules in a try block if you're expecting the presence of modules that aren't part…

Contents