Skip to content

Instantly share code, notes, and snippets.

@badp
Created June 24, 2010 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badp/451199 to your computer and use it in GitHub Desktop.
Save badp/451199 to your computer and use it in GitHub Desktop.
Quick and dirty pastebin interface in Pyhton
import urllib
valid_expiration_values = ('N', '10M', '1H', '1D', '1M')
def postToPastebin( message,
title = "RTBot",
subdomain = "rtbot",
expire_date = "1D",
format = "text"):
if expire_date not in valid_expiration_values:
raise Exception("invalid expire_date (must be one of %r, got %r instead)" % (valid_expiration_values, expire_date))
request_dict = { "paste_code": message,
"paste_name": title,
"paste_subdomain": subdomain,
"paste_expire_date": expire_date,
"paste_format": format }
request = urllib.urlencode(request_dict)
result = urllib.urlopen("http://pastebin.com/api_public.php", request)
return result.read() #either an error message or a pastebin url
@badp
Copy link
Author

badp commented Jun 24, 2010

Another piece of source code written to be best seen with elastic tabstops.

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