13 Jan 2022 Xavier Rigoulet The Python Requirements File and How to Create it Python requirements files are a great way to keep track of the Python modules. It is a simple text file that saves a list of the modules and packages required by your project. By creating a Python requirements.txt file, you save yourself the hassle of having to track down and install all of the required modules manually. In this article, we will learn how to create Python requirements files along with the best practices and the benefits of using them. Read more 23 Dec 2021 Xavier Rigoulet How to Download a File in Python Did you know you can download a file programmatically in Python? I will show you how to fetch and save a file in Python. This process is known as web scraping and is an essential step of any data-related project. Web scraping is the process of collecting data from a website. While it can be done manually by a user, it usually refers to an automated method of data collection with the help of a web crawler. Read more 16 Nov 2021 Xavier Rigoulet How to Write Custom Sort Functions in Python In computer science, a sorting algorithm puts elements of a list into a particular order. They are important because they often reduce the complexity of a problem. Let’s discover how to use custom sort functions to implement custom orders and comparisons in Python. In my previous article on working with streams in Python, I briefly introduced sorting methods with list.sort() and sorted(). Both list.sort() and sorted() have a key parameter that specifies a function to be called on each list element before making comparisons. Read more 9 Nov 2021 Xavier Rigoulet Map, Filter, Reduce – Working on Streams in Python Do you know how to work with Python streams like Java streams? A stream is a sequence of elements. With map(), filter(), and reduce() – the three cornerstone functions of functional programming – you can operate over a sequence of elements. In this article, we will learn how to work with streams in Python like we work with them in Java. But first, let’s say a word about functional programming. Read more 4 Nov 2021 Xavier Rigoulet How to Write to File in Python With Python, you can modify and write directly to a file programmatically, saving you the hassle of doing it manually. In this article, you will learn how to write to a file in Python. Before diving into the nitty-gritty of how to write to file in Python, I want to mention that I use Python 3.8.5 and Windows 10. However, your results should be the same on any operating system. Read more 2 Nov 2021 Xavier Rigoulet Things That Can Help You Write Better Python Code Do you wonder how to start learning programming with Python? Do you wonder how you can improve your Python code? Do you feel like you need to write better Python code but are unsure of what to do next? Do you feel like you’ve reached a plateau and struggle to get to the next level? In this article, I will go through a few things that can help you write better Python code. Read more 28 Oct 2021 Xavier Rigoulet How to Write a Custom Module in Python Do you wonder how you can write your own Python custom module, similar to famous Python libraries such as NumPy or Pandas? In my previous article for LearnPython.com, we learned about custom classes in Python. With Kateryna’s article on Python functions, you now have the required knowledge to implement your own custom module in Python. If you are still wondering why you should learn Python in 2021, check out Rebecca’s excellent article on the topic. Read more 7 Oct 2021 Xavier Rigoulet Simple Steps for Creating Your Own Class in Python Do you know how to build your own class in Python? Writing custom classes and custom objects in Python makes your code clearer, more readable, and easier to maintain. Before we start, if you still need some good reasons to learn Python, Rebecca can help you here. The concept of object-oriented programming emerged in the '60s, but its popularity did not start growing until the '90s. Today, object-oriented programming is everywhere and is an essential programming paradigm to understand. Read more 9 Sep 2021 Xavier Rigoulet How to Work With the Calendar and Arrow Python Modules During your journey as a developer or data scientist, you will have to work with dates and times. Fortunately, Python has several convenient libraries that make it easier. In this article, we’ll quickly review the datetime module, then examine the calendar and Arrow modules in Python. As a Python-using programmer, developer, data analyst, or data scientist, you’ll probably have to deal with date and time data quite often. Fortunately, Python’s datetime, calendar, and arrow libraries are available to streamline your tasks. Read more 27 May 2021 Xavier Rigoulet How to Rename Files Python How much time do you spend renaming your files? Do you wonder if you could do it more quickly and easily? What if you could rename a huge number of files in the blink of an eye? Python comes with multiple built-in modules and functions to do exactly that. In this article, you will learn how to use many of these modules and functions to rename and move files in Python. Read more «« « 1 2 3 4 » »»