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 refer to our video player troubleshooting guide for assistance.

Braced for the Future

00:00 There’s this module called __future__, which is a special module in Python. It doesn’t provide code like functions or variables or classes that you can import and use them.

00:11 Instead, it’s like a meta module, which allows you to change the behavior in Python. In other words, the goal of the __future__ module is to allow easier transition from older Python versions to newer Python versions, and that was especially important when Python 2 was the major version and they were trying to push people to Python 3.

00:32 So in order to make that transition easier, they introduced the __future__ module, which allowed you to change certain behaviors in Python. I remember that’s when you were switching from Python 2 to Python 3, and you wanted to write Python 3 compliant code in Python 2.

00:50 You could, for example, from __future__ import print_function, and then you could use the print() function already. Although in Python 2, it was still a print statement.

00:59 Exactly. There are also a few other things that you can enable or disable using this __future__ module, and one of those is braces.

01:08 When you import braces from __future__, people would hope that it would enable them to use curly brackets instead of whitespace and indentation to define code blocks.

01:19 Unfortunately, when you actually try importing braces from the __future__ module, it’s a little disappointing because instead of changing the behavior, you are getting a syntax error with a funny little message that says, “not a chance.” This is funny because a lot of people were requesting such a thing and well, Guido, who’s the creator of Python, really didn’t want to do that.

Become a Member to join the conversation.