From the course: Python Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Creating modules and packages

Creating modules and packages - Python Tutorial

From the course: Python Essential Training

Creating modules and packages

- Modules, packages, libraries, oh my. We've been using them throughout the course with the import statement. But what are these things actually? And what's going on under the hood? Okay, let's get this out of the way right up front. There's no real formal definition of a library in python. It's more of a general computer science word. It just means imported files. Code that you're referencing that lives somewhere else. When people say Python libraries, they could either be talking about a module or a package, but usually they're talking about a package. So with that in mind, we're going to focus on modules and packages. Let's go to the code. A module is literally just a Python file. And here I've created a file or a module called primes.py and it has two functions in it. IsPrime, which takes in a number and returns whether or not that number is prime. And listPrimes, which returns a list of primes up to that number.…

Contents