[pygtk] Doubt about tuple assignment

John Ehresman jpe at wingware.com
Fri Jun 13 05:17:35 WST 2008


Paolo Bacci wrote:
> I'm trying to assign a value into a specific position in a tuple but I 
> figured out that is not simple to do that and I nees a little help.
> 
> I have this input:
> 
>     a = [ (1,2) , (3,4) , (5,6) ]
> 
> 
> And I want this output:
> 
>     a = [ (1,2) , (3,*0*) , (5,6) ]

How about: a[1] = (3, 0)

> I tried with the python cmd line some inputs but the closest I got was 
> this one:
> 
>     a = a[:2-1] + (3,0) + a[2:]

This would need to be: a = a[:2-1] + [(3,0)] + a[2:]

Note that this is a generic python question and not pygtk specific.

Cheers,

John
> 
> 
> Note that [2-1], the number 2 will be replaced to a var in my final code.
> 
> But my outpu is being:
> 
>     (1,2) , (3,0), *0* , (5,6) 
> 
> 
> How can I take this 0 from the tuple and make it the right way?
> 
> Thanks,
> Paolo Bacci.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



More information about the pygtk mailing list