Did you know that by becoming an annual paid subscriber you not only get access to my weekly premium articles but can get one of my Udemy courses for free? Learning AI becomes more fun with videos! See the list of courses here. AI & Python #36: Python Libraries You Should LearnMultipurpose Python libraries that you’ll need regardless of your specialization.Everyone has been in a situation where they don’t know what to learn next or what to specialize in. You might like Python but that doesn’t mean you’ll learn every single library out there. You also don’t want to learn libraries that you may never use, so what should you do? Well, there are a few Python libraries that will come in handy regardless of the field you’re in. Whether you’re into web development or data analysis, you’d need these libraries to some degree. Here are some Python modules, libraries, and packages that you should learn whenever you don’t know what to learn next. OS/PathlibWorking with paths is something that anyone does sooner or later. Whether you’d like to export a dataset in a specific directory or read static files for your web application, you’d need to learn the OS or Pathlib modules. The OS and Pathlib are Python modules that allow us to do file system operations such as creating directories, listing directory content, working with paths, and more. But which one should you learn? OS or Pathlib? The OS and Pathlib modules have some similarities. With the OS module, you can manage paths, create folders, and more, but this module represents paths as string values. This limitation may sometimes lead you to search for workarounds that could be avoided by using the Pathlib module. Obtaining the parts of a path using Pathlib is as simple as calling an attribute. Let’s have a look.
Unlike OS, Pathlib works with objects that have properties and internal methods that make working with paths simpler. RequestsWhenever you need to interact with a server, you’ll have to use the Requests library. This is a Python library that you can use to send HTTP requests. HTTP is a request-response protocol between a client and a server that is the foundation of data exchange on the web. Why do you need that? Nowadays it’s very common to connect to third-party services using APIs, so we can get access to data such as tweets and the weather or add functionality to your web app like adding payment, translation, and email. If those APIs didn’t exist, you’d have to create those services from scratch! Fortunately, with APIs, we only need some minutes to get access to such services. That said, if you want to work with an API, you’ll need to send HTTP requests and receive responses. As you might guess, the Requests library is the perfect tool for this. Here’s an example of how I used the requests library to perform speech-to-text using this API.
But that’s not all! If you add a web scraping library like Beautiful Soup, you can even extract data from websites using requests. |