<s> """<STR_LIT>""" <EOL> __author__ = """<STR_LIT>""" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from os import getcwd <EOL> from os import sys <EOL> sys . path . append ( getcwd ( ) ) <EOL> import functools <EOL> from pprint import pprint as ppr <EOL> from MOAL . helpers . display import Section <EOL> from MOAL . helpers . display import print_h2 <EOL> from MOAL . helpers . datamaker import random_person_full <EOL> DEBUG = True if __name__ == '<STR_LIT:__main__>' else False <EOL> def cmp_people_lname ( val1 , val2 ) : <EOL> """<STR_LIT>""" <EOL> if val1 [ '<STR_LIT>' ] == val2 [ '<STR_LIT>' ] : <EOL> return <NUM_LIT:0> <EOL> if val1 [ '<STR_LIT>' ] > val2 [ '<STR_LIT>' ] : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return - <NUM_LIT:1> <EOL> def cmp_people_fname ( val1 , val2 ) : <EOL> """<STR_LIT>""" <EOL> if val1 [ '<STR_LIT>' ] == val2 [ '<STR_LIT>' ] : <EOL> return <NUM_LIT:0> <EOL> if val1 [ '<STR_LIT>' ] > val2 [ '<STR_LIT>' ] : <EOL> return <NUM_LIT:1> <EOL> else : <EOL> return - <NUM_LIT:1> <EOL> @ functools . total_ordering <EOL> class Person ( object ) : <EOL> def __init__ ( self ) : <EOL> self . person = random_person_full ( ) <EOL> def __eq__ ( self , other ) : <EOL> return self . person [ '<STR_LIT>' ] == other . person [ '<STR_LIT>' ] <EOL> def __lt__ ( self , other ) : <EOL> return self . person [ '<STR_LIT>' ] < other . person [ '<STR_LIT>' ] <EOL> def _mult_tup ( x , y ) : <EOL> t1 , t2 = y <EOL> return t1 * t2 <EOL> def _concat ( x , y ) : <EOL> return x + y <EOL> def greet ( name , greeting = '<STR_LIT>' , prefix = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> prefix = '<STR_LIT>' . format ( prefix ) if prefix else '<STR_LIT>' <EOL> return '<STR_LIT>' . format ( greeting , prefix , name ) <EOL> def helloer ( ) : <EOL> """<STR_LIT>""" <EOL> return functools . partial ( greet , greeting = '<STR_LIT>' ) <EOL> def halloer ( ) : <EOL> """<STR_LIT>""" <EOL> return functools . partial ( greet , greeting = '<STR_LIT>' ) <EOL> def halloer_male ( ) : <EOL> """<STR_LIT>""" <EOL> return functools . partial ( <EOL> greet , prefix = '<STR_LIT>' , greeting = '<STR_LIT>' ) <EOL> def halloer_female ( ) : <EOL> """<STR_LIT>""" <EOL> return functools . partial ( <EOL> greet , prefix = '<STR_LIT>' , greeting = '<STR_LIT>' ) <EOL> if DEBUG : <EOL> with Section ( '<STR_LIT>' ) : <EOL> print_h2 ( '<STR_LIT>' ) <EOL> p1 = random_person_full ( ) <EOL> p2 = random_person_full ( ) <EOL> resfirst = sorted ( [ p1 , p2 ] , cmp_people_fname ) <EOL> reslast = sorted ( [ p1 , p2 ] , cmp_people_lname ) <EOL> ft_resfirst = sorted ( <EOL> [ p1 , p2 ] , key = functools . cmp_to_key ( cmp_people_fname ) ) <EOL> ft_reslast = sorted ( <EOL> [ p1 , p2 ] , key = functools . cmp_to_key ( cmp_people_lname ) ) <EOL> ppr ( [ resfirst , reslast ] ) <EOL> ppr ( [ ft_resfirst , ft_reslast ] ) <EOL> print_h2 ( '<STR_LIT>' ) <EOL> p1 = Person ( ) <EOL> p2 = Person ( ) <EOL> print ( p1 == p2 ) <EOL> print ( p1 < p2 ) <EOL> print ( p1 > p2 ) <EOL> print ( p1 >= p2 ) <EOL> print_h2 ( '<STR_LIT>' ) <EOL> f = range ( <NUM_LIT:10> , <NUM_LIT:20> ) <EOL> g = range ( <NUM_LIT:100> , <NUM_LIT:200> ) <EOL> h = zip ( f , g ) <EOL> print ( h ) <EOL> print ( functools . reduce ( _mult_tup , h ) ) <EOL> strings = [ '<STR_LIT:hello>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:?>' ] <EOL> assert functools . reduce ( _concat , strings ) == '<STR_LIT>' <EOL> print_h2 ( '<STR_LIT>' ) <EOL> print ( helloer ( ) ( '<STR_LIT>' ) ) <EOL> print ( halloer ( ) ( '<STR_LIT>' ) ) <EOL> print ( halloer_male ( ) ( '<STR_LIT>' ) ) <EOL> print ( halloer_female ( ) ( '<STR_LIT>' ) ) <EOL> print_h2 ( '<STR_LIT>' ) </s>
