code: def pythonise(id, encoding='ascii'):
      
      replace = {'-': '_', ':': '_', '/': '_'}
      func = lambda id, pair: id.replace(pair[0], pair[1])
      id = reduce(func, replace.iteritems(), id)
      id = '_%s' % id if id[0] in string.digits else id
      return id.encode(encoding)
docs: Return a Python-friendly id