Explain Codes LogoExplain Codes Logo

Python

How can I remove a key from a Python dictionary?

python
key-removal
dictionary
best-practices

Limiting floats to two decimal points

python
decimal-arithmetic
float-limitation
precision-matters

How do I detect the Python version at runtime?

python
python-version
version-control
python-3

How to Customize Site Title, Site Header, and Index Title in Django Admin?

python
django-admin
customization
template-engineering

Convert Pandas column containing NaNs to dtype `int`

python
pandas
dataframe
best-practices

Using Python 3 in virtualenv

python
virtualenv
python-3
best-practices

How can I do relative imports in Python?

python
relative-imports
python-modules
package-structure

How to re-import an updated package while in Python Interpreter?

python
importlib
module-reloading
python-advanced

How to Convert List to String

python
list-conversions
string-conversions
pythonic-code

How to print a date in a regular format?

python
date-formatting
datetime-module
string-formatting

Get all object attributes in Python?

python
object-attributes
python-attributes
getattr

What can I do about "ImportError: Cannot import name X" or "AttributeError: ... (most likely due to a circular import)"?

python
circular-dependencies
import-best-practices
module-design

How do I read from stdin?

python
input
stdin
io

How do I concatenate two lists in Python?

python
functions
collections
best-practices

How do I merge two dictionaries in a single expression in Python?

python
dataframe
pandas
best-practices

Running shell command and capturing the output

python
subprocess
shell-execution
error-management

How do I correctly clean up a Python object?

python
contextlib
resource-management
best-practices

Does Python have a string 'contains' substring method?

python
functions
performance
best-practices

Finding and replacing elements in a list

python
list-comprehension
functional-programming
data-structures

Check if something is (not) in a list in Python

python
performance
best-practices
dataframe