April Fool's PEP
00:00 So while these kind of braces aren’t in Python and won’t be in Python, there is an operator that was actually implemented and it has to do with some kind of brackets as well.
00:14 In Python 2, you had two different ways to express inequality, either with the exclamation point and an equal sign like in C family languages or with the diamond operator, which is the less than followed by greater than operator, which is very popular in languages like Pascal and probably others too.
00:37 On April 1st in 2009, they issued a Python enhancement proposal. PEP 401, which references April 1st for is April and first is 01 where they claim that Guido, the creator of Python, was retire and be replaced by Barry Warsaw, who is also one of the popular figures in Python.
01:01 He is one of the core developers, people call him Friendly Language Uncle for Life or FLUFL. And in that document they claim that Barry would introduce some changes that Guido wouldn’t approve of, including the rein statement of the diamond operator.
01:20 Normally if you want to compare two values, say we’re comparing two integers, we’d use the inequality operator, but in Python 2 you could also use the diamond operator consisting of the set less than and greater than operator.
01:36 In Python 3, this is a syntax error, it’s not possible. But when we run Python 2 and try the same code, you can actually use both operators just fine and they work the same.
01:50 When we go back to Python 3, when you import various levels from future, it reverses this change. So now the regular inequality operator no longer works, which is displaced this funny syntax error with a message with various PDFL, which is another acronym in Python.
02:08 Do you know what it stands for? Philip Benevolent Dictator for Life. Yeah, that’s right. So this is the official title of Guido, the creator of Python. And with this PEP, Barry becomes the new BDFL.
02:22 And with that now you have to use the old diamond operator instead of the usual inequality operator, we can try compare one unequal to two and we’re getting the expected result now.
02:36 Interesting. It’s a little funny Easter egg in Python, so this time actually importing something from future does change the syntax and I think that’s such a great example for an Easter egg and without me, for example, knowing the whole story behind it, it shows me that the developers had fun and were kind of like making jokes of, of each other by implementing something like this and it’s super nice to see that stuff is still around and you can explore this.
03:05 Yeah, I’m wondering what Easter eggs there are that we don’t know of yet, and we’re going to find out in maybe a few years. Who knows?
Become a Member to join the conversation.