Modules, Packages, and File Operations

Learning Objectives

By the end of this chapter, you will be able to:

  • Describe what Python modules are and create your own
  • Describe what Python packages are and create your own
  • Work with the built-in Python modules
  • Describe the file object in Python
  • Read and write to Python files
  • Work with structured data in Python files

This lesson introduces Python modules and packages. We also cover file operations available to us in Python.


In the previous chapter, we have covered object-oriented programming in depth. We have covered important OOP concepts such as classes, methods, and inheritance. In this chapter, we will take a look at modules and file operations.

When you are working on any ...

Get Python Fundamentals now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.