GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — learn-python/src/operators/test_identity.py at master · mirekwilmer/learn-python Expand file tree/ Copy pathtest_identity.pyMore file actions 35 lines (25 loc) · 1.14 KB / Copy pathtest_identity.pyFile metadata and controls35 lines (25 loc) · 1.14 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 """Identity operators @see: https://www.w3schools.com/python/python_operators.asp Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location. """ def test_identity_operators(): """Identity operators""" # Let's illustrate identity operators based on the following lists. first_fruits_list = ["apple", "banana"] second_fruits_list = ["apple", "banana"] third_fruits_list = first_fruits_list # is # Returns true if both variables are the same object. # Example: # first_fruits_list and third_fruits_list are the same objects. assert first_fruits_list is third_fruits_list # is not # Returns true if both variables are not the same object. # Example: # first_fruits_list and second_fruits_list are not the same objects, even if they have # the same content assert first_fruits_list is not second_fruits_list # To demonstrate the difference between "is" and "==": this comparison returns True because # first_fruits_list is equal to second_fruits_list. assert first_fruits_list == second_fruits_list |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |