Skip to content

Instantly share code, notes, and snippets.

@brettkelly
Created April 20, 2011 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettkelly/932159 to your computer and use it in GitHub Desktop.
Save brettkelly/932159 to your computer and use it in GitHub Desktop.
Select a random snippet and write it to STDOUT
#!/usr/bin/env python
import random, sys
# define our list of candidate snippets
s = ["%snippet:typo1%","%snippet:typo2%","%snippet:typo3%"]
# select one at random and write it to STDOUT
sys.stdout.write(random.choice(s))
@givens
Copy link

givens commented Dec 24, 2012

Your snippet is a helpful text expander snippet. For whatever reason, I needed to modify the code just slightly before I got it to work:

!/usr/bin/python

import random

L = [",,bren",",,adp",",,sbio",",,gmail"] # pre-selected snippets
l = "%snippet:"+random.choice(L)+"%"

print(l)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment