Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
FlipFlop operator in Python
class FlipFlop: # the objects should be used by single thread def __init__(self, entry, exit): self.conditions = entry, exit self.state = False def __call__(self, value): if self.conditions[self.state](value): self.state = not self.state return self.state #__bool__ = None # to don't forget about calling the object if __name__ == '__main__': condition = FlipFlop('<'.__eq__, '>'.__eq__) while True: try: line = input() except EOFError: break else: print(''.join(c.upper() if condition(c) else c for c in line))
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Filtering texts within brackets
(P3) Zadanie Kolokwium 2013: Trójkąty i trójkąty
Yyy
shuru15
Prime numbers
Python code
31 dec
Find numbers with given sum of digits
jhjhh
try123
stackse - search stackoverflow differently
Please log in to post a comment.