Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Side Effects: Troubleshooting

00:00 I’m going to drop down and create an entry point of if __name__ == '__main__': we’ll just call get_holidays(). And let’s print that return value.

00:14 Let’s open up the terminal and run the program called And we get this AssertionError and this looks like something left over.

00:26 Right, so we made this saturday and we’re testing, “Is it a weekday?” So let’s do an assert not, so this should resolve this AssertionError. Let’s try that again.

00:42 And we get an interesting ImportError here, cannot import name 'timegm' from 'calendar'. This is where the calendar file is and I believe it’s because when we imported requests,

00:58 there’s probably another module called calendar, so I think we need to actually change the name of this file. So let’s go ahead and I’m just going to copy calendar to my_calendar, and then we’ll open up

01:22 I’m going to close the original calendar. And let’s see if we can run

01:33 And that did not work either. Maybe I actually have to remove the, so let’s try to remove

01:45 And then we’ll try this once again. Okay, great. So that was just because the requests underneath the hood was using a module called and there was a naming conflict.

01:59 So we’ve renamed the file and now we’re actually getting a response from requests. Since I don’t have a /holidays endpoint running on my machine—and I’m assuming you don’t either—you’re going to get a ConnectionError.

02:16 This is a requests.exception, we have—let’s see what it says. Failed to establish a new connection […] Connection refused, because I don’t have this endpoint running on localhost port 80.

02:29 So this is what happens when you run get_holidays() and there is no server at this particular URL.

Become a Member to join the conversation.