From a PHP developer’s perspective, Python’s tuples can seem quite peculiar. They are like PHP’s array, but they are immutable, and sometimes, they even appear to be “invisible”! Immutability is covered in another section, so here, let’s focus on this “invisibility.”
Consider this example code:
def my_func():
x = 1
y = 2
return x, y
This might lead PHP developers to wonder:
“Wait, can Python functions actually return two separate values at once? If so, how on earth would we handle them?”