List of Python3 related pages
-
Checking if a Python list is empty
There are several ways to check if a list contains any elements, such as using “if not”, the built-in len function, or comparing it to an empty array. -
Printing to Standard Error (stderr) in Python
By default, the print function prints a string to standard output (stdout), but you can specify a different output destination with the file argument. When you pass sys.stderr as this argument, the print function prints the string to standard error. You can also use the write method of sys.stderr to output, but unlike the print function, it does not automatically insert a newline. -
Python - Doing nothing with an if statement
When you don’t want to do anything in an if statement when a condition is met or not met, you can use the pass statement. -
Python - Error No module named ‘PIL’ occurs
The error ModuleNotFoundError: No module named 'PIL' occurs when the image processing library Pillow is not installed. To resolve this, install Pillow using the pip command. -
Python - Getting the Absolute Value
To get the absolute value, you can use the built-in function abs, the fabs function from the math module, and the fabs function from the cmath module. -
Python - Preventing Line Breaks with the print Function
If you don’t want to output a line break with the print function, specify an empty string for the end argument. -
Python - Wait for a specified time (sleep / wait)
To stop a program (thread) for a specified time, use the sleep function of the time module.