Python Development: Creating Classes, Handling Errors, & Importing Modules

Python    |    Beginner
  • 9 videos | 1h 16m 23s
  • Includes Assessment
  • Earns a Badge
Rating 4.7 of 201 users Rating 4.7 of 201 users (201)
Python classes act like blueprints for establishing a new type of object with its own set of properties and methods. In this course, you'll learn how to define and instantiate classes in Python. You'll start by using the init() method to initialize your class's member variables and the self keyword to reference a class's current instance. You'll then illustrate the differences between the self keyword in Python and the "this" keyword in Java. Next, you'll examine how errors in Python can be handled using the try-except-finally block and how the error handling mechanism in Python is similar to Java exception handling. Finally, you'll import other Python libraries into your current Python program, using classes and functions defined in one Python file in another file using the import statement. When you're finished with this course, you'll be able to set up Python classes for various uses in your development projects.

WHAT YOU WILL LEARN

  • Discover the key concepts covered in this course
    Define and use classes in python
    Initialize classes using the __init__() method
    Use try and except blocks to catch potential errors in code
    Use the finally block to write clean up code
  • Import modules into your current program
    Reference a custom module written in a different python file
    Pass and reference command line arguments in python
    Summarize the key concepts covered in this course

IN THIS COURSE

  • 2m 8s
    In this video, you’ll learn more about your instructor and the course. You’ll learn to define and instantiate classes in Python. You’ll discover the use of the init method to initialize member variables of a class and how to use self keyword arguments to reference current instances of a class. You’ll learn the differences between the self keyword in Python and the this keyword in Java. You’ll also learn how to handle errors in Python. FREE ACCESS
  • 8m 36s
    In this video, you’ll watch a demo. In this demo, you’ll learn how to conduct an exploration of support for classes and instances in Python. You’ll discover Python has support for classes, objects, inheritance. First, you’ll start by defining a simple class. You’ll investigate its functionality and then try out that functionality. FREE ACCESS
  • Locked
    3.  Defining Methods within Python Classes
    12m
    In this video, you’ll watch a demo. In this demo, you’ll learn how member variables, specifically instance variables, are defined in Python. First, you’ll begin by redefining the class created in the last demo. Inside that class, you have a new method called init, specifically __init__. init takes in one input argument. Then, inside the body of this method you have a print statement which reads Instance initialized. Next, you’ll learn about this code. FREE ACCESS
  • Locked
    4.  Catching Exceptions Using Python's Try Except Blocks
    11m 38s
    In this video, you’ll watch a demo. In this demo, you’ll learn about exceptions and errors in Python. You’ll learn that Python is interpreted and not compiled. This means there is no question of any difference between runtime and checked exception as exists in Java. You’ll also learn the terms error and exception can be used interchangeably. Finally, you’ll learn that in Python, syntax errors are a kind of exception. FREE ACCESS
  • Locked
    5.  Using Python's Finally Block
    4m 29s
    In this video, you’ll watch a demo. In this demo, you’ll learn to raise an exception. You’ll discover in Python, the keyword for this is raise. In Java, you have try catch blocks. In Python you have try except blocks. In Java, you throw an exception. In Python, you raise one. You’ll follow along onscreen to raise an exception. Then, you’ll pass in arguments in the try block. This is followed by an except block. FREE ACCESS
  • Locked
    6.  Importing Python Modules
    10m 36s
    In this video, you’ll watch a demo. This demo serves as a quick introduction to modules and packages. First, you’ll learn that in Python, the term module refers to any organizational unit of code. In Python, a package is also a module. You’ll learn a Python package is a module with a __path__ attribute. Every package is a module, but not every module is a package. Packages have a directory structure and contain multiple modules. FREE ACCESS
  • Locked
    7.  Creating Simple Python Modules
    12m 4s
    In this video, you’ll watch a demo. This demo is about special variable names and about how the import of modules works in Python. You will use Python from the terminal window rather than Jupyter notebooks. You will also use the Sublime Text editor. You’ll run Python from the command line, and then you will define a class. FREE ACCESS
  • Locked
    8.  Parsing Command Line Arguments in Python
    11m 55s
    In this video, you’ll watch a demo. This demo deals with command line arguments from Python Programs. In this demo, you will continue to use Python from the command line. You'll have the Python code in the Sublime text editor. You’ll run code from the terminal window. First, you’ll start by importing sys. This module is required when working with command line arguments. FREE ACCESS
  • Locked
    9.  Course Summary
    2m 58s
    In this video, you’ll review what you’ve learned in the course. You’ve learned to create and instantiate classes in Python. You also learned to define classes and create class variables. You learned about the __init__ method and how to use the try-except block to catch potential errors. You learned about the else block and the finally block. You also learned about package installers and how the process of importing one Python file into another works. FREE ACCESS

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.6 of 10 users Rating 4.6 of 10 users (10)
Rating 4.5 of 226 users Rating 4.5 of 226 users (226)
Rating 4.6 of 2165 users Rating 4.6 of 2165 users (2165)