This file contains hidden or 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
Traceback (most recent call last): | |
... | |
data = [(entry['key'], entry['count']) for entry in response['data']['subtotal']] | |
TypeError: 'NoneType' object is unsubscriptable |
This file contains hidden or 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
Traceback (most recent call last): | |
... | |
data = [(entry["key"], entry["count"]) for entry in response["data"]['subtotal']] | |
TypeError: 'NoneType' object is unsubscriptable | |
Locals at innermost frame: | |
{ 'foo': [], | |
'bar': True, |
This file contains hidden or 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
import pprint | |
MAX_VARS_LINES = 30 | |
MAX_LINE_LENGTH = 100 | |
class VerboseExceptionFormatter(logging.Formatter, object): | |
def __init__(self, log_locals_on_exception=True, *args, **kwargs): | |
self._log_locals = log_locals_on_exception |
This file contains hidden or 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
Beware of hasattr(). It will return False on *any* exception. This is rarely what you want. | |
>>> class Thing(object): | |
... @property | |
... def foo(self): | |
... return self.this_will_raise_attribute_error | |
... @property | |
... def bar(self): | |
... return 1 / 0 # ZeroDevisionError... | |
>>> |
This file contains hidden or 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/bin/env python | |
""" | |
TODO: replace this with http://flake8.readthedocs.org/en/latest/#flake8 ? | |
Combines pep8 and pyflakes output for emacs; | |
treats pep8 as warnings, pyflakes as errors. | |
From https://bitbucket.org/keegan_csmith/dotfiles/raw/tip/misc/pyflakespep8.py | |
modified a bit by slinkp. |
This file contains hidden or 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
(when (load "flymake" t) | |
;; For Python, I use pyflakes combined with pep8 via a little script | |
;; that mashes them up. Might want to try flake8 (see pypi) ... it | |
;; adds a complexity checker. | |
(defun flymake-pyflakespep8-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) |
This file contains hidden or 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
try: | |
print "hi", nothing | |
except NameError: | |
print "ok" |
This file contains hidden or 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
Check out the tornado source. | |
Switch to the branch1.2. | |
Apply this patch: | |
diff --git a/website/website.py b/website/website.py | |
index 39b7aed..902be9a 100644 | |
--- a/website/website.py | |
+++ b/website/website.py | |
@@ -49,6 +49,7 @@ settings = { | |
"template_path": os.path.join(os.path.dirname(__file__), "templates"), |
This file contains hidden or 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
{"body": "This code: https://github.com/openplans/openblock/blob/master/ebpub/ebpub/geocoder/base.py#L498\r\n\r\nruns into a few problems when convert_to_block is True. Seems it's been copied from somewhere else but not fully adapted. For easier reference the code is:\r\n\r\n{{{\r\n#!python\r\n except InvalidBlockButValidStreet, e:\r\n # If the exact address couldn't be geocoded, try using the\r\n # normalized location name.\r\n if convert_to_block:\r\n block_name = address_to_block(kwargs['location_name'])\r\n if block_name != kwargs['location_name']:\r\n try:\r\n result = BlockGeocoder._do_geocode(block_name)\r\n result['result']['address'] = block_name\r\n except InvalidBlockButValidStreet, another_e:\r\n pass\r\n except AmbiguousResult, another_e:\r\n pass\r\n # No joy, return all blocks.\r\n logger.debug('Invalid block for %r, |
This file contains hidden or 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
Python packages matching "spam" on pypi: | |
========================================= | |
Note i'm marking things that only deal with moderation, manual | |
flagging, and the like, as irrelevant. | |
RELEVANT | |
----------------------------------------------------- |