diff options
| -rw-r--r-- | example.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/example.py b/example.py new file mode 100644 index 0000000..c717ef2 --- /dev/null +++ b/example.py @@ -0,0 +1,43 @@ +""" +blockext spec +for tim +because he's too good for a doc file + +Example code: +""" + +import blockext + +blockext.PORT = 1234 + +@blockext.predicate("/tf") +def tf(): + blockspec = "true or false" + return random.choice(True, False) + + +@blockext.reporter("/weather", blocking=True) +def weather(city): + blockspec = "current weather in %s" + return weatherIn(city) + +@blockext.reporter("/light") +def light(): + blockspec = "light sensor value" + return lightsensor.get() + +@blockext.stack("/move") +def move(degrees): + blockspec = "move %n degrees" + move(degrees) + +blockext.generate_extension(blockext.SCRATCH, "extension.json") +blockext.generate_extension(blockext.SNAP, "extension.xml") +if __name__ == "__main__": + blockext.run() + + +# I suppose a launcher could do that on demand + +# Or run() could do it for you. Really I wanted you to think about *why* you're +# doing stuff. |
