Skip to content

Instantly share code, notes, and snippets.

View zeyneloz's full-sized avatar

zeynel ozdemir zeyneloz

View GitHub Profile
// HTTPError implements ClientError interface.
type HTTPError struct {
Cause error `json:"-"`
Detail string `json:"detail"`
Status int `json:"-"`
}
func (e *HTTPError) Error() string {
if e.Cause == nil {
return e.Detail
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
import random
spaceships = {...}
def get_random_ship():
# Generate a random spaceship id
id = random.randint(0, 100000000)
return spaceships[id] # KeyError ?
import random
spaceships = {...}
def get_random_ship():
key_list = list(spaceships.keys())
# Pick a random key from key list
id = random.choice(key_list)
return spaceships[id]
import random
spaceships = {...}
key_list = list(spaceships.keys())
def get_random_ship():
id = random.choice(key_list)
return spaceships[id]