On 19/05/11 17:26, Andre Engels wrote:
On Thu, May 19, 2011 at 8:15 AM, Joe Aquilina<[email protected]> wrote:
I realised after I read your response that I probably hadn't included enough
information, partly due to my inexperience in Python and partly due to
haste on my part.
AFter my original post, I had a little play in Python and was able to create
this tuple:
[1, 2, 3, 4, 5]
from which I was able to extract any item I wanted as an integer and work
with as I wanted. I am guessing that this is a 1-tuple.
No, this is an array. However, an array and a tuple work similarly in
many cases. A 1-tuple is a tuple with one element, so this is
definitely not a 1-tuple.
It is when I do the fetchall() from the table, that I get the following:
[(1,), (2,), (3,)]
I don't know enough to know whether this is a 1-tuple or not. It is from
this tuple that I want to extract the 3 as an integer so that I can
increment it and save as an integer into the next row in the table.
This again is an array, but this time the elements are tuples (indeed
1-tuples). To show you how to get the value 3 from this:
A = [(1,), (2,), (3,)]
A[2]
(3,)
A[-1]
(3,)
B = A[-1]
B
(3,)
B[0]
3
A[-1][0]
3
I see now, and understand how it works. This is a lot simpler and easier
than what I tried yesterday.
Thanks again.
Joe Aquilina.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor