Skip to content

Instantly share code, notes, and snippets.

@renpytom
Created February 29, 2020 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renpytom/3df4feb702e8c2a45486f6e36c9fd348 to your computer and use it in GitHub Desktop.
Save renpytom/3df4feb702e8c2a45486f6e36c9fd348 to your computer and use it in GitHub Desktop.
init python:
class ConditionSub(object):
def __init__(self, *args):
self.items = [ (cond, value) for cond, value in zip(args[::2], args[1::2]) ]
def __unicode__(self):
for cond, value in self.items:
if eval(cond):
return self.value
default is_cat = True
define pet = ConditionSub("is_cat", "cat", "True", "dog")
label start:
"I have a [pet]."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment