-
-
Save barraponto/7140704 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 time import sleep | |
from os import linesep as delimiter | |
from twisted.internet import stdio | |
from twisted.protocols import basic | |
from twisted.internet import reactor | |
class WakeUpCall(basic.LineReceiver): | |
def connectionMade(self): | |
self.transport.write('Up?') | |
def lineReceived(self, line): | |
self.sendLine('Let\'s Party!') | |
class Party: | |
def __init__(self, name, people): | |
self.name = name | |
self.all_night = True | |
self.people = people | |
people = ["Capi", "Mobi", "Pedro", "Marcela", "Gabi", "Carla"] | |
party = Party("Python com Pimenta", people) | |
if "Marcela" in party.people: | |
sleep(10) # Dorme ae :D | |
stdio.StandardIO(WakeUpCall()) # Mas bota um despertador | |
reactor.run() # E dorme assíncrono! | |
while party.all_night: | |
print "All night party!!!" # Estamos te esperando! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment