Back to index

python3.2  3.2.2
Classes | Functions
hanoi Namespace Reference

Classes

class  Tkhanoi

Functions

def hanoi
def main

Function Documentation

def hanoi.hanoi (   n,
  a,
  b,
  c,
  report 
)

Definition at line 19 of file hanoi.py.

00019 
00020 def hanoi(n, a, b, c, report):
00021     if n <= 0: return
00022     hanoi(n-1, a, c, b, report)
00023     report(n, a, b)
00024     hanoi(n-1, c, b, a, report)
00025 
00026 
# The graphical interface

Here is the call graph for this function:

def hanoi.main ( void  )

Definition at line 127 of file hanoi.py.

00127 
00128 def main():
00129     import sys
00130 
00131     # First argument is number of pegs, default 4
00132     if sys.argv[1:]:
00133         n = int(sys.argv[1])
00134     else:
00135         n = 4
00136 
00137     # Second argument is bitmap file, default none
00138     if sys.argv[2:]:
00139         bitmap = sys.argv[2]
00140         # Reverse meaning of leading '@' compared to Tk
00141         if bitmap[0] == '@': bitmap = bitmap[1:]
00142         else: bitmap = '@' + bitmap
00143     else:
00144         bitmap = None
00145 
00146     # Create the graphical objects...
00147     h = Tkhanoi(n, bitmap)
00148 
00149     # ...and run!
00150     h.run()
00151 
00152 
# Call main when run as script