Advanced Python Topics: Exceptions & Command Line Arguments


Overview/Description
Expected Duration
Lesson Objectives
Course Number
Expertise Level



Overview/Description

In this 11-video course, learners can examine different types of exceptions that can be raised in Python and how they can be handled with except blocks. Explore execution of Python scripts from the command line, including use and parsing of command-line arguments. To begin, use a try and except block to handle a Python exception, then learn how to handle exceptions that your code may raise. Explore how exceptions are defined in a hierarchy and how related exceptions are caught and handled. Next, define multiple except blocks to handle various exceptions that can be raised by code; convert code prototyped in a Jupyter notebook into a Python script that can be executed from a shell, and run code from the Python shell and execute single-line and multi-line commands. Learn about parsing command line arguments, and use the sys and argparse module to access command-line arguments to a Python script, then parse and use the arguments passed to a Python script from the command line. Finally, learn to define command-line arguments by using argparse.



Expected Duration (hours)
1.2

Lesson Objectives

Advanced Python Topics: Exceptions & Command Line Arguments

  • discover the key concepts covered in this course
  • use a try and except block to handle a Python exception
  • control how you handle exceptions that your code may raise
  • recognize how exceptions are defined in a hierarchy and how related exceptions can be caught and handled
  • define multiple except blocks to handle various exceptions that can be raised by your code
  • convert code prototyped in a Jupyter notebook into a Python script that can be executed from a shell
  • run your code from the Python shell and recognize how to execute single-line and multi-line commands
  • use the sys and argparse module to access command line arguments to a Python script
  • parse and use the arguments passed to a Python script from the command line
  • define the names and other customizable features of command line arguments to a Python script using the argparse module
  • summarize the key concepts covered in this course
  • Course Number:
    it_pyatpydj_02_enus

    Expertise Level
    Beginner