converting from perl: variable sized unpack

John Machin machin_john_888 at hotmail.com
Sat Jul 14 18:36:52 EDT 2001


Roy Smith <roy at panix.com> wrote in message news:<roy-B49CE8.09521914072001 at news1.panix.com>...
> James Logajan <JamesL at Lugoj.Com> wrote:
> > This may not be the most elegant or efficient, but how about this:
> > 
> > [f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6]
> 
> Yeah, that's what I had come up with, but I was hoping somebody would have 
> an idea that was more elegant and efficient :-)

Strive for correctness first, then worry about elegance and efficiency
-- this "solution" does not fulfill your original request that the
extra fields be populated with null strings; it drops None objects in
instead.



More information about the Python-list mailing list