How-to articles, tricks, and solutions about PYTHON
How to convert list to string
You can use the join() method to convert a list of strings to a single string.
Converting from a string to boolean in Python
In Python, you can use the bool() function to convert a string to a boolean.
What are the most common Python docstring formats?
There are several common formats for Python docstrings, including:
Get unique values from a list in python
In Python, you can use the set() function to get the unique values from a list.
How to parse XML and get instances of a particular node attribute?
You can use the xml library in Python to parse XML and get instances of a particular node attribute.
What is a cross-platform way to get the home directory?
The os.path module in Python provides a cross-platform way to get the home directory.
How do you test that a Python function throws an exception?
You can use the pytest.raises function to test that a Python function throws an exception.
Is there a simple way to delete a list element by value?
Yes, you can use the remove() method to delete a list element by its value.
How do I install a Python package with a .whl file?
To install a Python package with a .whl file, you can use the pip command.
Get the data received in a Flask request
In a Flask application, you can access the data received in a request using the request object.
"Large data" workflows using pandas
Here is an example of a workflow for handling large data using the pandas library:
Get difference between two lists with Unique Entries
You can use the set data type to find the difference between two lists with unique entries.
Difference between del, remove, and pop on lists
del: The del keyword is used to remove an item from a list by its index.
Fastest way to check if a value exists in a list
The fastest way to check if a value exists in a list is to use the in operator.
How do I get a list of locally installed Python modules?
You can use the pip module to get a list of locally installed Python modules.