How-to articles, tricks, and solutions about PYTHON
IndentationError: unindent does not match any outer indentation level
This error occurs when there is a mismatch in the indentation level of a block of code in Python.
Is it possible to break a long line to multiple lines in Python?
Yes, it is possible to break a long line of code into multiple lines in Python.
Is there a built-in function to print all the current properties and values of an object?
In Python, you can use the built-in function vars() to print the properties and values of an object.
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.
Limiting floats to two decimal points
To limit a float to two decimal points, you can use the round() function.
List attributes of an object
In Python, you can use the built-in function dir() to list the attributes of an object.
Manually raising (throwing) an exception in Python
In Python, you can raise an exception using the raise statement.
Matplotlib make tick labels font size smaller
Here is a code snippet that shows how to make the tick labels font size smaller in Matplotlib:
Meaning of @classmethod and @staticmethod for beginner
In Python, @classmethod is a decorator that is used to define a method as a class method.