קוד review. מפתח כותב:
python
def get_coordinates():
return [37.7749, -122.4194] # San Francisco
lat, lon = get_coordinates()נראה תקין. אבל יש בעיה: list היא mutable. מישהו בצוות עלול לכתוב:
python
coords = get_coordinates()
coords.append(0) # "הוספתי altitude..."
# עכשיו lat, lon = coords יזרוק ValueErrorהפתרון ש-Python תכננה בדיוק לזה:
python
def get_coordinates():
return (37.7749, -122.4194) # tuple - immutabletuple מתקשרת כוונה: "הנתונים האלה לא אמורים להשתנות". ו-Python תאכוף את זה.