Skip to content

Commit

Permalink
proper fibonacci sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
SavinaRoja committed Mar 5, 2013
1 parent 29326ca commit 0d6d875
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.py[cod]
*~

# C extensions
*.so
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PyKeyboardEvent, so here's an example of subclassing PyMouseEvent:
from pymouse import PyMouseEvent

def fibo():
a = 1
a = 0
yield a
b = 1
yield b
Expand Down
26 changes: 26 additions & 0 deletions examples/clickonacci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pymouse import PyMouseEvent

def fibo():
a = 0
yield a
b = 1
yield b
while True:
a, b = b, a+b
yield b

class Clickonacci(PyMouseEvent):
def __init__(self):
PyMouseEvent.__init__(self)
self.fibo = fibo()

def click(self, x, y, button, press):
'''Print Fibonacci numbers when the left click is pressed.'''
if button == 1:
if press:
print(self.fibo.next())
else: # Exit if any other mouse button used
self.stop()

C = Clickonacci()
C.run()

0 comments on commit 0d6d875

Please sign in to comment.