Skip to content

Instantly share code, notes, and snippets.

@RomainTT
Created February 21, 2019 14:48
Show Gist options
  • Save RomainTT/4591babbace4e367d6dc46753b4cf5d8 to your computer and use it in GitHub Desktop.
Save RomainTT/4591babbace4e367d6dc46753b4cf5d8 to your computer and use it in GitHub Desktop.
Python notes

This file is used to store some tips and tricks I collect while programming in Python.

Native Python

Finding a substring within a list in Python

When a single string is looked for in a list of strings by providing a sub-string, here is the solution with the lowest execution time:

s = next((s for s in slist if subs in s), None)

# Faster than
s = [s for s in slist if subs in s][0]

Jupyter

Export to slides

jupyter nbconvert notebook.ipynb --to slides --post serve --SlidesExporter.reveal_theme=serif --SlidesExporter.reveal_scroll=True --SlidesExporter.reveal_transition=none --reveal-prefix "http://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment