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
Verifying that +stuartmyles is my blockchain ID. https://onename.com/stuartmyles |
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
import ast | |
# ast code to figure out how to call an instance object method and pass in a parameter, i.e. equivalent to | |
# result = self._baz(theResult)" | |
class Greeter: | |
def _baz(self, theStr): | |
return theStr | |
def baz(self, theResult): |
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
import ast | |
# ast code to call an instance object method and pass in a parameter, i.e. equivalent to | |
# result = self._baz(theResult)" | |
class Greeter: | |
def _baz(self, theStr): | |
return theStr | |
def baz(self, theResult): |
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
import ast | |
# ast code to call a function _bar(), pass in a value and assign the returned value to a variable called "result", i.e. equivalent to | |
# result = _bar("theResult") | |
def _bar(theStr): | |
return theStr | |
assignresult = ast.Module(body=[ ast.Assign(targets = [ | |
ast.Name(id = 'result', ctx = ast.Store())], | |
value = ast.Call(func = ast.Name(id='_bar', ctx = ast.Load()), ctx = ast.Load(), args=[ast.Name(id="theResult", ctx = ast.Load())], keywords=[])) |
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
import ast | |
# ast code to call a function _foo() and assign the returned value to a variable called "result", i.e. equivalent to | |
# result = _foo() | |
def _foo(): | |
return "It worked!" | |
assignresult = ast.Module(body=[ ast.Assign(targets = [ |
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
# Use ast to generate an abstract syntax tree to assign an empty tuple to a variable named "nothing" | |
# i.e. equivalent to | |
# nothing = () | |
import ast | |
emptyness = ast.Module(body=[ ast.Assign(targets = [ | |
ast.Name(id = 'nothing', ctx = ast.Store())], | |
value = ast.Tuple(elts=[], ctx = ast.Load())) | |
]) |
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
import ast | |
class Greeter: | |
def __init__(self): | |
#m = "Hello world!" | |
assignment = ast.Module(body=[ ast.Assign(targets = [ | |
ast.Name(id = 'm', ctx = ast.Store())], | |
value = ast.Str(s="Hello world!")) |
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
{ | |
"competionid": "123456", | |
"eventid": "78901", | |
"competionname": "FIFA World Cup 2014", | |
"eventname": "FIFA World Cup 2014 Final", | |
"competitionstartdate": "2014-12-06", | |
"compeitionenddate": "2014-13-07", | |
"eventstartdate": "2014-07-13T19:00Z", | |
"eventtimeelapsed": "54", | |
"eventvenueid": "111668", |
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
{ | |
"competionid": "123456", | |
"eventid": "78901", | |
"competionname": "FIFA World Cup 2014", | |
"eventname": "FIFA World Cup 2014 Final", | |
"competitionstartdate": "2014-12-06", | |
"compeitionenddate": "2014-13-07", | |
"eventstartdate": "2014-07-13T19:00Z", | |
"eventtimeelapsed": "54", | |
"eventvenueid": "111668", |
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
# An example of how to use AWS SNS with Python's boto | |
# By Stuart Myles @smyles | |
# http://aws.amazon.com/sns/ | |
# https://github.com/boto/boto | |
# | |
# Inspired by parts of the Ruby SWF SNS tutorial http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-sns-tutorial-implementing-activities-poller.html | |
# And the Python SNS code in http://blog.coredumped.org/2010/04/amazon-announces-simple-notification.html and http://awsadvent.tumblr.com/post/37531769345/simple-notification-service-sns | |
import boto.sns as sns | |
import json |
NewerOlder