diff options
| -rw-r--r-- | doc/tutorial.rst | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 2a67371..5167a87 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -18,29 +18,26 @@ Example ------- Blockext is a Python module that makes writing extensions for these block-based -programming languages much, much easier. It probably couldn't get any easier. +programming languages fairly easy. Here's a quick example:: from blockext import * + + class Extension: + def __init__(self): + light = False - light = False - - @command("press light switch %n times") - def toggle_light(times=1): - global light - for i in range(times): - light = not light - - @predicate("light is on?") - def is_light_on(): - return light + def toggle_light(times=1): + global light + for i in range(times): + light = not light - menu("city", ["Barcelona", "Boston", "Brighton"]) + def is_light_on(): + return light - @reporter("weather forecast for %m.city") - def forecast(city="Boston"): - import random - return random.choice(["windy", "snowy", "sunny"]) + def forecast(city="Boston"): + import random + return random.choice(["windy", "snowy", "sunny"]) run("Tutorial Example", "example", 5000) |
