Explain Codes LogoExplain Codes Logo

Python

How can I randomly select an item from a list?

python
random-selection
secrets-module
list-manipulation

What's the best practice using a settings file in Python?

python
best-practices
settings
environment-variables

Why is __init__() always called after __new__()?

python
design-patterns
singleton
immutable-types

How do I parse an ISO 8601-formatted date?

python
date-parsing
datetime
error-handling

How can I add new keys to a dictionary?

python
dictionary
update
key-management

Pandas read in table without headers

python
pandas
dataframe
csv

Writing a list to a file with Python, with newlines

python
file-handling
context-managers
json

How to comment out a block of code in Python

python
commenting
best-practices
ide-shortcuts

How do I check file size in Python?

python
file-size
pathlib
file-handling

How to take column-slices of dataframe in pandas

python
pandas
dataframe
slicing

Pythonw.exe or python.exe?

python
python-gui
error-handling
logging

How can the Euclidean distance be calculated with NumPy?

python
euclidean-distance
numpy
vectorization

How to count the frequency of the elements in an unordered list?

python
collections
counter
groupby

Proper indentation for multiline strings?

python
multiline-strings
readability
docstrings

Determine the type of an object?

python
type-checking
duck-typing
best-practices

How to recursively find files in Python

python
pathlib
os-walk
file-search

Disable output buffering

python
output-buffering
sys-module
subprocess

How do I get the last element of a list?

python
negative-indexing
list-manipulation
functions

Converting Dictionary to List?

python
list-comprehension
memory-management
dictionary-comprehensions

Finding the average of a list

python
performance
statistics
numpy