Another question about variable args.
Steven W. Orr
steveo at syslang.net
Tue Aug 7 12:09:31 EDT 2007
I have a structure I need to pack. I call struct.pack about a dozen times
and each call takes about 53 arguments.
I create a sequence of the arguments:
a1 = 1
a2 = 2
a3 = 3
etc...
a54 = 88
myseq = (a1, a2, a3, a4 etc... a53)
Also I made
def mpack ( fmt, *ss ):
print type(ss)
for ii in ss:
print 'ii = ', ii, 'type(ii) = ', type(ii)
for ii in list(ss):
print 'ii = ', ii, 'type(ii) = ', type(ii)
return struct.pack(fmt, *ss )
In my main, this first print statement works.
print 'main:', mpack(ff, a, b, c, d, e, f, g, h, i)
1. For the life of me, I can't figure out what to do to get the next print
to work. The idea is that I want to make my code clearer by not passing
50+ args each time and to instead pass a sequence which when evaluated
will be the desired list of args.
print 'main:', mpack(ff, subseq)
2. And then, if possible, I'd like to do it in such a way that one myseq
is defined, its value can automagically be re-eval'd so I don't have to
re-assign to myseq each time one of the 50+ variables changes prior to
calling pack.
Does this make sense?
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
More information about the Python-list
mailing list