Explain Codes LogoExplain Codes Logo

Python

In Python, how do I determine if an object is iterable?

python
iterable
collections
iterators

A weighted version of random.choice

python
numpy
random-choice
weighted-random-choice

Selecting distinct column values in SQLAlchemy/Elixir

python
sqlalchemy
database-queries
distinct-values

How do I check if a list is empty?

python
best-practices
pythonic
efficiency

How to call a shell script from python code?

python
subprocess
shell-script
process-management

Substitute multiple whitespace with single whitespace in Python

python
functions
performance
best-practices

How do I call a function from another .py file?

python
importlib
python-imports
module-importation

Clear terminal in Python

python
terminal-management
escape-sequences
subprocess

Disable Tensorflow debugging information

python
logging
tensorflow
best-practices

How to use "get_or_create()" in Django?

python
django
get_or_create
tuple

Calling a function of a module by using its name (a string)

python
dynamic-invocation
getattr
importlib

Getting a map() to return a list in Python 3.x

python
list-comprehension
map-function
performance-optimization

How do I check if a string represents a number (float or int)?

python
functions
best-practices
code-readability

How to make a class JSON serializable

python
json-serialization
custom-methods
object-serialization

Automatically create requirements.txt

python
pipreqs
requirements-txt
dependency-management

Importerror: No module named sklearn.cross_validation

python
importerror
scikit-learn
pip-install

How do I access the ith column of a NumPy multidimensional array?

python
numpy
multidimensional-arrays
column-access

Integrating Python Poetry with Docker

python
virtual-environments
docker
poetry

Best way to convert string to bytes in Python 3?

python
encode-decode
string-conversion
unicode-encoding

Why do people write "#!/usr/bin/env python" on the first line of a Python script?

python
prompt-engineering
best-practices
version-management