How-to articles, tricks, and solutions about PYTHON
Getting a list of all subdirectories in the current directory
Here is a code snippet in Python that gets a list of all subdirectories in the current directory:
How to identify which OS Python is running on?
You can use the platform module in Python to identify which operating system the code is running on.
What does -> mean in Python function definitions?
In Python, the "->" symbol is used to indicate the return type of a function.
Convert date to datetime in Python
You can convert a date to datetime in Python using the datetime module.
What is a clean "pythonic" way to implement multiple constructors?
A "pythonic" way to implement multiple constructors in Python is to use the @classmethod decorator.
Writing a list to a file with Python, with newlines
Here is a code snippet that demonstrates how to write a list to a file with newlines in Python:
How do you get the logical xor of two variables in Python?
You can use the ^ operator to get the logical XOR of two variables in Python.
How do I detect whether a variable is a function?
In Python, you can use the built-in callable() function to check if a variable is a function.