tuple with dangling comma; cx_Oracle oddity
I came across this odd sort of tuple lately. I'm dying to know what's up with it.
>>> x = (1,)
What does this dangling comma mean?
I can't find any use for the concept.
>>> x == (1, None)
False
>>> x == (1)
False
>>> len(x)
1
>>> x[1]
Traceback (most recent call last):
File "", line 1, in
IndexError: tuple index out of range
>>> list(x)
[1]
Does anyone know what this is supposed to mean, or why it's possible, or what good it might do?
Incidentally, I got it from cx_Oracle as the result of a query on one column. Is that expected behavior?
cursor.execute('SELECT 1, 2 FROM dual')
cursor.fetchone()
(1, 2)
cursor.execute('SELECT 1 FROM dual')
cursor.fetchone()
(1,)
Thanks!
>>> x = (1,)
What does this dangling comma mean?
I can't find any use for the concept.
>>> x == (1, None)
False
>>> x == (1)
False
>>> len(x)
1
>>> x[1]
Traceback (most recent call last):
File "
IndexError: tuple index out of range
>>> list(x)
[1]
Does anyone know what this is supposed to mean, or why it's possible, or what good it might do?
Incidentally, I got it from cx_Oracle as the result of a query on one column. Is that expected behavior?
cursor.execute('SELECT 1, 2 FROM dual')
cursor.fetchone()
(1, 2)
cursor.execute('SELECT 1 FROM dual')
cursor.fetchone()
(1,)
Thanks!
