getting info out of a list.
anton muhin
antonmuhin.REMOVE.ME.FOR.REAL.MAIL at rambler.ru
Mon Jun 16 07:36:00 EDT 2003
Jim Richardson wrote:
> I have the following code
>
> for wires in wirelist.keys():
> bits=wirelist[wires]
> Wire=("GW",wires,bits)
> print Wire
>
>
> Which, depending on the data in wirelist, results in something like,
>
> ('GW', 1, (11, 0, -500, 0, 0, 500, 0, 10))
>
>
> But what I want is
>
> ('GW', 1, 11, 0, -500, 0, 0, 500, 0, 10)
>
> I want the tuple that is returned from the dict wirelist, to be added as
> individual elements, rather than a tuple of individual elements, to the
> list "bits"
>
> (I hope I have explained this properly)
>
>
> I know I am missing something fundamental, but I can't figure out what.
> Any suggestions on where to look? or what I am missing? Thanks.
>
>
And just my two cents: your for loop could be rewritten a little bit
more effeciently and (IMHO) clearly:
for wires, names in wirelist.iteritems():
Wire = ("GW", wires) + bits
print Wire
hth,
anton
More information about the Python-list
mailing list