$ python -c "print('True' if None < 0 else False)"
True
$ python3 -c "print('True' if None < 0 else False)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: unorderable types: NoneType() < int()
$ python -c "print('True' if None < 0 else False)"
True
$ python3 -c "print('True' if None < 0 else False)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: unorderable types: NoneType() < int()
a = [1, 2, 3] | |
b = [4, 5, 6] | |
zipped = zip(a,b) | |
# zipped = [(1, 4), (2, 5), (3, 6)] | |
unzipped = zip(*zippped) | |
# unzipped = [(1, 2, 3), (4, 5, 6)] | |
# get back a, b |
"""Sequence generator | |
$ python sequence.py 3 | |
[3] | |
[2, 1] | |
[1, 1, 1] | |
$python sequence.py 6 | |
[6] |
"""Copied from http://hunterford.me/django-custom-model-manager-chaining/ | |
Reference: http://www.dabapps.com/blog/higher-level-query-api-django-orm/ | |
usage: | |
Post.objects.published() | |
Post.objects.by_author(user=request.user).published() | |
""" | |
from django.db import models | |
"""Print Fibonacci series using generator""" | |
import argparse | |
import textwrap | |
def fibonacci(number): | |
"""Fibonacci series generator""" | |
previous, current = 0, 1 | |
counter = 0 |