Skip to content

Instantly share code, notes, and snippets.

@benoitguigal
Last active May 4, 2019 01:40
Show Gist options
  • Save benoitguigal/32341a2930dbc2f619c05acdf269bc3a to your computer and use it in GitHub Desktop.
Save benoitguigal/32341a2930dbc2f619c05acdf269bc3a to your computer and use it in GitHub Desktop.
Python
# Get all letters of the alphabet
import string
all_letters = string.ascii_letters + " .,;'"
# List all files in a directory matching a pattern
import glob
def findFiles(path): return glob.glob(path)
findFiles("/somedir/*.txt")
# Get the name of a file, stripping the extension
name = os.path.splitext(os.path.basename(filename))[0]
# Find the index of char in a string
"abcdef".find("b")
# Generator for dict
{x: datasets.ImageFolder(os.path.join(data_dir, x), data_transforms[x])
for x in ['train', 'val']}
# Get pip tags compatible with your platform
import pip
pip.pep425tags.get_supported()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment