def speak(animal, session): """ Retrieves the sound for the given animal, and prints it with animation. """ response = session.get('https://ericappelt.com/animals/{0}'.format(animal)) sound = response.text radprint('The {0} says "{1}".'.format(animal, sound))
def speak(animal, printlock): """ Retrieves the sound for the given animal, and prints it with animation. """ session = requests.Session() response = session.get('https://ericappelt.com/animals/{0}'.format(animal)) sound = response.text printlock.acquire() radprint('The {0} says "{1}".'.format(animal, sound)) printlock.release() session.close()
def speak(animal, printlock): """ Retrieves the sound for the given animal, and prints it with animation. """ session = requests.Session() response = session.get( 'https://ericappelt.com/animals/{0}'.format(animal) ) sound = response.text with printlock: if 'Moo' in sound: raise ValueError('Not happy about moo.') radprint('The {0} says "{1}".'.format(animal, sound)) session.close()