HowTos
Free Video Tutorials
Written Tutorials
💲Paid Courses
Python Shell
Mailing List
About Us
Home/
Top Python How-To Questions
Extract extension from filename.
python
filenames
file-extension
Print to stderr in Python.
python
stderr
printing
zen-of-python
Generate random integers between 0 and 9.
python
random
integer
Measure elapsed time in Python.
python
time
measure
Read from stdin (standard input).
python
stdin
read
Get the class name of an instance.
python
class name
instance
Check if a string is empty.
python
string
check
empty
Pad zeroes to a string.
python
string
pad zeros
Delete an element from a dictionary.
python
dictionary
delete element
Check if a string is a float.
python
check type
float
Count the occurrences of an item in a list.
python
list
count
Remove a trailing newline.
python
newline
trailing
Print literal curly-brace characters in a string and also use .format on it.
python
string
format
curly-braces
string-formatting
Determine the type of an object.
python
list
types
tuple
str
dict
int
Limit floats to two decimal points.
python
floating-point
rounding
precision
Know if an object has an attribute.
python
attributes
object
Select an item from a list randomly.
python
list
random
Read a file line-by-line into a list.
python
string
file
readlines
Call a function of a module by using its name.
python
object
function-call
Get the number of elements in a list.
python
list
len
count
Print without a newline or space.
python
print
space
newline
Sort a list of dictionaries by a value of the dictionary.
python
list
dictionary
sorting
data-structures
Rename column names with Pandas.
python
dataframe
pandas replace
rename
Parse a string to a float or integer.
python
floating-point
type-conversion
integer
parsing
Convert a string into datetime format.
python
datetime
convert
Print coloured text on the terminal.
python
output
terminal
ansi-colors
Find current directory of a file.
python
directory
file-directory
Split a list into evenly sized parts.
python
list
split
chunks
Select rows from a DataFrame based on column values with Pandas.
python
pandas
dataframe
Check if a given key already exists in a dictionary.
python
dictionary
dictionary-key
Top Python What Questions
Are static class variables possible in Python?
python
oop
class-variables
static
class
What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
parameter-passing
python syntax
argument-unpacking
variadic-functions
Python Classes and OOP Explained
oop
object oriented programming
classes
Should I use a for-loop or a list comprehension in Python?
python
list comprehension
comparing
for-loop
faster
What is the difference between a staticmethod and a classmethod in Python?
python
classmethod vs staticmethod
static method
instance method
class method
What does "yield" do in a Python function?
python
yield
generator
What is if __name__ == "__main__" in Python?
python
__main__
__name__==
Go to Top
Become a Patron
Do you like my work and would want to contribute? You can become a patron on my Patreon below!
Become a Patron