def create_new_paste(contents):
 import re
 if (sys.version_info < (3, 0)):
  from urllib import urlopen, urlencode
 else:
  from urllib.request import urlopen
  from urllib.parse import urlencode
 params = {'code': contents, 'lexer': ('python3' if (sys.version_info[0] == 3) else 'python'), 'expiry': '1week'}
 url = 'https://bpaste.net'
 response = urlopen(url, data=urlencode(params).encode('ascii')).read()
 m = re.search('href="/raw/(\\w+)"', response.decode('utf-8'))
 if m:
  return ('%s/show/%s' % (url, m.group(1)))
 else:
  return ('bad response: ' + response)

def create_new_paste ( contents ) : import re if ( sys . version_info < ( 3 , 0 ) ) : from urllib import urlopen , urlencode else : from urllib . request import urlopen from urllib . parse import urlencode params = { 'code' : contents , 'lexer' : ( 'python3' if ( sys . version_info [ 0 ] == 3 ) else 'python' ) , 'expiry' : '1week' } url = 'https://bpaste.net' response = urlopen ( url , data = urlencode ( params ) . encode ( 'ascii' ) ) . read ( ) m = re . search ( 'href="/raw/(\\w+)"' , response . decode ( 'utf-8' ) ) if m : return ( '%s/show/%s' % ( url , m . group ( 1 ) ) ) else : return ( 'bad response: ' + response )
creates a new paste using bpaste .