"is" vs "==" in Python – What's the Difference? (And When to Use Each)
Автор: Real Python
Загружено: 2016-12-27
Просмотров: 74872
https://dbader.org/python-tricks ► Write clean & Pythonic code and start using advanced features in your Python code
It's easy to get tripped up by Python's "is" and "==" operators for object comparison. In this video I'll explain the difference with a few easy to understand examples.
There's a difference in meaning between equal and identical. And this difference is important when you want to understand how Python's is and == comparison operators behave.
The == operator compares by checking for equality - the "is" operator, however, compares identities.
The difference between them breaks down to down to two short definitions:
An is expression evaluates to True if two variables point to the same (identical) object.
An == expression evaluates to True if the objects referred to by the variables are equal (have the same contents).
Check out this tutorial if you want to drill deeper: https://dbader.org/blog/difference-be...
FREE COURSE – "5 Thoughts on Mastering Python" https://dbader.org/python-mastery
PYTHON TRICKS: THE BOOK https://dbader.org/pytricks-book
SUBSCRIBE TO THIS CHANNEL: https://dbader.org/youtube
* *
► Python Developer MUGS, T-SHIRTS & MORE: https://nerdlettering.com
FREE Python Tutorials & News:
» Python Tutorials: https://dbader.org
» Python News on Twitter: / @dbader_org
» Weekly Tips for Pythonistas: https://dbader.org/newsletter
» Subscribe to this channel: https://dbader.org/youtube
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: