''' On May 6, 4:43 pm, [EMAIL PROTECTED] honoring: >>> a.next( ) ( "I", ) >>> a.throw( up ) ( "I", "A" ) >>> a.next( ) ( "I", "B" ) >>> a.next( ) ( "I", "C" ) >>> a.throw( down ) ( "II", ) '''
#funny declaration class up( Exception ): pass class down( Exception ): pass def outline( ): stack= [ 1 ] while 1: try: yield stack stack[ -1 ]+= 1 except up: stack.append( 1 ) except down: stack.pop( -1 ) stack[ -1 ]+= 1 a= outline( ) print a.next( ) print a.throw( up ) print a.next( ) print a.next( ) print a.throw( down ) print a.throw( up ) print a.throw( up ) print a.next( ) print a.next( ) print a.throw( down ) ##output: [1] [1, 1] [1, 2] [1, 3] [2] [2, 1] [2, 1, 1] [2, 1, 2] [2, 1, 3] [2, 2] ## cf. formatter.NullFormatter.format_counter formatter.NullFormatter.format_letter formatter.NullFormatter.format_roman -- http://mail.python.org/mailman/listinfo/python-list