Search⌘ K
AI Features

Let's Meet Friendly Language Uncle for Life

Explore the diamond operator discussed in PEP-401, an uncommon feature in Python 3, and understand its use and limitations. Learn about hidden Python gems and how to access these features using eval or compile for improved coding insight.

We'll cover the following...

Have you ever used the diamond operator (<>) in Python? Let’s see what it does.

⚠️ The following code is meant for Python 3.x versions.

Python 3.5
>>> from __future__ import barry_as_FLUFL
>>> "Ruby" != "Python" # there's no doubt about it
File "some_file.py", line 1
"Ruby" != "Python"
^
SyntaxError: invalid syntax
>>> "Ruby" <> "Python"
True
Terminal 1
Terminal
Loading...

There we go. ...