The following code does not print what I would expect:
#!/usr/bin/env python
print type(1,)
a = 1,
print type(a)
Here is the output:
<type 'int'>
<type 'tuple'>
I understand that the comma makes a into a tuple. But if that is the case how come the original print is not printing a tuple type but an int?
Because the tuple syntax inside a function call is also the way parameters are passed:
It is a syntax ambiguity for python, which it solves by deciding that you are trying to pass a parameter (if you ask me, it should be a syntax error though).
Are the same.