This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book: | |
... | |
def __hash__(self): | |
return hash(self.author) ^ hash(self.other) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book: | |
... | |
def __lt__(self, other): | |
return (self.author, self.title) < (other.author, other.title) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Config: | |
def __init__(self, **entries): | |
self.entries = entries | |
def __add__(self, other): | |
entries = (self.entries.items() + | |
other.entries.items()) | |
return Config(**entries) | |
default_config = Config(color=False, port=8080) | |
config = default_config + Config(color=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Awkward | |
for options_shortcut in self.options_shortcuts: | |
options_shortcut.this() | |
options_shortcut.that() | |
# Better | |
for each in self.options_shortcuts: | |
each.this() | |
each.that() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instead of this | |
self.release_water() | |
self.shutdown() | |
self.alarm() | |
class Reactor: | |
... | |
def release_water(self): | |
self.valve.open() | |
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Meh | |
def match(self, items): | |
for each in items: | |
if each.match(self): | |
return each | |
# Is this supposed to reach the end? Is this a bug? | |
# Better | |
def match(self, items): | |
for each in items: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/.ideas.md | |
# Software | |
- doomed startup idea 1 | |
- some feature for an open-source project | |
- doomed startup idea 2 | |
- ... | |
# Blog posts | |
- the .ideas file |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------ | |
/usr/local/bin/pip run on Mon Jul 1 12:34:07 2013 | |
Downloading/unpacking lxml | |
Getting page https://pypi.python.org/simple/lxml/ | |
URLs to search for versions for lxml: | |
* https://pypi.python.org/simple/lxml/ | |
Analyzing links from page https://pypi.python.org/simple/lxml/ | |
Skipping link https://pypi.python.org/packages/2.4/l/lxml/lxml-1.3.4.win32-py2.4.exe#md5=3007a5b7556d5115e34da2e220630d1d (from https://pypi.python.org/simple/lxml/); unknown archive format: .exe | |
Skipping link https://pypi.python.org/packages/2.7/l/lxml/lxml-2.2.8-py2.7-win32.egg#md5=62180a1bf41e037cd2712957fa4acf62 (from https://pypi.python.org/simple/lxml/); unknown archive format: .egg |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------ | |
/usr/local/bin/pip run on Mon Jul 1 12:34:07 2013 | |
Downloading/unpacking lxml | |
Getting page https://pypi.python.org/simple/lxml/ | |
URLs to search for versions for lxml: | |
* https://pypi.python.org/simple/lxml/ | |
Analyzing links from page https://pypi.python.org/simple/lxml/ | |
Skipping link https://pypi.python.org/packages/2.4/l/lxml/lxml-1.3.4.win32-py2.4.exe#md5=3007a5b7556d5115e34da2e220630d1d (from https://pypi.python.org/simple/lxml/); unknown archive format: .exe | |
Skipping link https://pypi.python.org/packages/2.7/l/lxml/lxml-2.2.8-py2.7-win32.egg#md5=62180a1bf41e037cd2712957fa4acf62 (from https://pypi.python.org/simple/lxml/); unknown archive format: .egg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------ | |
/usr/local/bin/pip run on Mon Jul 1 12:47:31 2013 | |
Downloading/unpacking lxml | |
Running setup.py egg_info for package lxml | |
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url' | |
warnings.warn(msg) |