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
In [1]: class Foo(object): | |
...: pass | |
...: | |
In [2]: def bar(self): | |
...: pass | |
...: | |
In [3]: bar.__get__ | |
Out[3]: <method-wrapper '__get__' of function object at 0x10fdc6398> |
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
In [16]: def counter_factory(): | |
....: count = [0] | |
....: def _counter(): | |
....: count[0] += 1 | |
....: return count[0] | |
....: return _counter | |
....: | |
In [17]: f = counter_factory() |
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
In [13]: def counter_factory(): | |
....: count = 0 | |
....: def _counter(): | |
....: count += 1 | |
....: return _counter | |
....: | |
In [14]: f = counter_factory() | |
In [15]: f() |
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
In [31]: def create_counter(): | |
....: def _counter(): | |
....: global count | |
....: count += 1 | |
....: return count | |
....: return _counter | |
....: | |
In [32]: f = create_counter() |
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
>>> def create_counter(): | |
... count = 0 | |
... def _counter(): | |
... nonlocal count | |
... count += 1 | |
... return count | |
... return _counter | |
... | |
>>> f = create_counter() | |
>>> f() |
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
In [1]: class Foo(object): | |
...: def bar(self): | |
...: print 'hi' | |
...: | |
In [2]: f = Foo() | |
In [3]: f.__dict__['bar']() | |
--------------------------------------------------------------------------- | |
KeyError Traceback (most recent call last) |
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
{"res":0,"hash":"52829d29e9a09","btype":0,"barg":0,"fp":10,"waves":[{"seq":"1","monsters":[{"type":0,"num":"476","lv":3,"item":"476","inum":3,"pval":0},{"type":0,"num":"479","lv":3,"item":0,"inum":0,"pval":0}]},{"seq":"2","monsters":[{"type":0,"num":"220","lv":8,"item":0,"inum":0,"pval":0}]},{"seq":"3","monsters":[{"type":0,"num":"412","lv":3,"item":0,"inum":0,"pval":0}]},{"seq":"4","monsters":[{"type":0,"num":"284","lv":5,"item":0,"inum":0,"pval":0}]},{"seq":"5","monsters":[{"type":0,"num":"215","lv":5,"item":"33","inum":5,"pval":0}]},{"seq":"6","monsters":[{"type":0,"num":"596","lv":4,"item":"596","inum":4,"pval":0}]}]} |
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
$ curl -i https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=sfmta_muni | |
HTTP/1.1 400 Bad Request | |
content-length: 61 | |
content-type: application/json; charset=utf-8 | |
date: Wed, 13 Nov 2013 22:04:41 UTC | |
server: tfe | |
set-cookie: guest_id=v1%3A138438028115535261; Domain=.twitter.com; Path=/; Expires=Fri, 13-Nov-2015 22:04:41 UTC | |
strict-transport-security: max-age=631138519 | |
{"errors":[{"message":"Bad Authentication data","code":215}]} |
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
from foo import (bar, | |
baz, | |
quux | |
) | |
# or | |
from foo import bar | |
from foo import baz | |
from foo import quux |
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
on run argv | |
tell application "Alfred 2" | |
search item 1 of argv | |
tell application "System Events" | |
keystroke "l" using {command down} | |
end tell | |
end tell | |
end run |