Skip to content

Instantly share code, notes, and snippets.

View kennethlove's full-sized avatar
🦀
Python

Kenneth Love kennethlove

🦀
Python
View GitHub Profile
from __future__ import print_function
from collections import namedtuple
import random
# Create an easy-to-return and easy-to-inspect data
# structure for Game results.
Results = namedtuple('Results', ['won', 'switched'])
from __future__ import print_function
import logging
from sys import exit
from random import randint
logging.basicConfig(filename='game.log', level=logging.DEBUG)
try:
# raw_input became input in Python 3
input = raw_input
import unittest
def is_prime(n):
if n in (2, 3):
return True
if n < 2 or n % 2 == 0:
return False
if n < 9:
return True
class Car(Model):
make = CharField()
model = CharField()
year = IntegerField()
@classmethod
def add_car(cls, make, model, year):
try:
cls.create(make=make, model=model, year=year)
except IntegrityError:
;;; packages.el --- writing Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
import xml.etree.ElementTree as ET
def get_hosts(tree_root):
'''Takes an ETree root
For every sin in a given xml_file, return a list containing the FQDN.
'''
return [server.get('host') for server in tree_root.iter('sin')]
@kennethlove
kennethlove / books.py
Last active December 5, 2018 00:26
Smarter book object.
class Book:
title = ''
pages = 0
def __init__(self, title='', pages=0):
self.title = title
self.pages = pages
def __add__(self, other):
"""Control adding two Books together or a Book and a number"""
from random import choice
from moves import Rock, Paper, Scissors
class Game:
def __init__(self, rounds=3):
self.rounds = rounds
self.player = input("What's your name? ")
self.score = [0, 0]

Keybase proof

I hereby claim:

  • I am kennethlove on github.
  • I am kennethlove (https://keybase.io/kennethlove) on keybase.
  • I have a public key whose fingerprint is 7ADE 253B 0A52 B295 F5FD FB52 4254 D672 C5D3 B12C

To claim this, I am signing this object:

Traceback (most recent call last):
File "/Users/martin/Projects/md5checker/playground/md5checker/tests.py", line 15, in test_new_md5hash_derived_field
self.assertEqual(m.md5, md5)
AssertionError: '' != '9a618248b64db62d15b300a07b00580b'
+ 9a618248b64db62d15b300a07b00580b