import magic

magic.from_file("iceland.jpg")
# Example output "JPEG image data, JFIF standard 1.01".

magic.from_file("iceland.jpg", mime=True)
# Example output "image/jpeg".

magic.from_file("greenland.png")
# Example output "PNG image data, 600 x 1000, 8-bit colormap, non-interlaced".

magic.from_file("greenland.png", mime=True)
# Example output "image/png".
os.path.basename(os.path.normpath("/folderA/folderB/folderC/folderD/"))
# Example output "folderD".
i = ["title", "email", "password2", "password1", "first_name", "last_name", "next", "newsletter"]
a, b = i.index("password2"), i.index("password1")
i[b], i[a] = i[a], i[b]
# To get the first 100 characters from myString variable.
# Returned as a string.
myString[:100]
# To get the last 100 characters from myString variable.
# Returned as a string.
myString[:-100]
string = "Special $#! characters   spaces 888323"
"".join(e for e in string if e.isalnum())