> [] * []
0
Why is this?
Because, it seems that []
gets cast to a 0
when performing arithmetic.
import string | |
def is_pangram(sentence): | |
""" | |
A pangram is a sentence that contains every letter of the alphabet. This | |
function determines whether the given sentence is a pangram. | |
>>> is_pangram('the quick brown fox jumps over the lazy dog') | |
True | |
""" |
> [] * []
0
Why is this?
Because, it seems that []
gets cast to a 0
when performing arithmetic.
$ ansible vagrant -a 'ls /home' | |
vagrant-host | success | rc=0 >> | |
vagrant | |
$ ansible vagrant -a 'cd /home' | |
vagrant-host | FAILED | rc=2 >> | |
[Errno 2] No such file or directory |
$ tree | |
. | |
├── Dockerfile | |
├── index.html | |
├── index.js | |
└── package.json | |
$ docker build . | |
Uploading context 6.144 kB | |
Uploading context |
from urllib2 import urlopen | |
from multiprocessing.pool import ThreadPool | |
from multiprocessing.pool import Pool | |
from gevent.pool import Pool as GEPool | |
from timeit import timeit | |
from pprint import pprint | |
urls = [ | |
'http://www.python.org', |
#include "SDL2/SDL.h" | |
#include <stdio.h> | |
void clear(SDL_Renderer * renderer) { | |
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); | |
SDL_RenderClear(renderer); | |
SDL_RenderPresent(renderer); | |
} |
""" | |
Write logic that dynamically outputs a string of 35 characters. | |
The string is composed of 7 distinct letters. Each letter is used 5 times. | |
Any subset of 3 characters must be unique from any other subset of 3 characters. | |
Any subset of 3 characters can only have zero or ONE of the same letter. | |
""" | |
from collections import Counter | |
from itertools import permutations | |
def sequences(seq, n=3): |
<html> | |
<body> | |
<div id="hierarchy"></div> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.2/mustache.min.js"></script> | |
<script type="text/template" id="recursive-partial"> | |
{{#children}} | |
<li>{{name}} |
import re | |
from operator import * | |
def lisp(s_exp): | |
""" Evaluate pseudo-lisp. | |
`s_exp` should be a string of an s-expression. | |
If the first item in the s-exp isn't callable then the s-exp will be | |
treated like a literal list. |
from types import MethodType | |
from functools import wraps | |
def decorate_methods(decorator): | |
""" | |
Return a class decorator that will decorate public methods with the given decorator. | |
""" | |
def class_decorator(klass): | |
for name in dir(klass): | |
if name.startswith('_'): |