<s> from collections import namedtuple <EOL> Human = namedtuple ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> luke = Human ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> homePlanet = '<STR_LIT>' , <EOL> ) <EOL> vader = Human ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> homePlanet = '<STR_LIT>' , <EOL> ) <EOL> han = Human ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> homePlanet = None , <EOL> ) <EOL> leia = Human ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> homePlanet = '<STR_LIT>' , <EOL> ) <EOL> tarkin = Human ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> ] , <EOL> homePlanet = None , <EOL> ) <EOL> humanData = { <EOL> '<STR_LIT>' : luke , <EOL> '<STR_LIT>' : vader , <EOL> '<STR_LIT>' : han , <EOL> '<STR_LIT>' : leia , <EOL> '<STR_LIT>' : tarkin , <EOL> } <EOL> Droid = namedtuple ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> threepio = Droid ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> primaryFunction = '<STR_LIT>' , <EOL> ) <EOL> artoo = Droid ( <EOL> id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , <EOL> friends = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> appearsIn = [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> primaryFunction = '<STR_LIT>' , <EOL> ) <EOL> droidData = { <EOL> '<STR_LIT>' : threepio , <EOL> '<STR_LIT>' : artoo , <EOL> } <EOL> def getCharacter ( id ) : <EOL> return humanData . get ( id ) or droidData . get ( id ) <EOL> def getFriends ( character ) : <EOL> return map ( getCharacter , character . friends ) <EOL> def getHero ( episode ) : <EOL> if episode == <NUM_LIT:5> : <EOL> return luke <EOL> return artoo <EOL> def getHuman ( id ) : <EOL> return humanData . get ( id ) <EOL> def getDroid ( id ) : <EOL> return droidData . get ( id ) </s>
