converting from perl: variable sized unpack
s713221 at student.gu.edu.au
Sat Jul 14 16:46:23 CEST 2001
> >[f1, f2, f3, f4, f5, f6] = (string.split (line) + 6*[None])[:6]
> My variant is:
> f1, f2, f3, f4, f5, f6 = map(lambda x, y: x, string.split(line), 6*[None])
> f1, f2, f3, f4, f5, f6 = pad(string.split(line), 6, None)
I've noticed that everyone is using string.split. Is there a reason why
we aren't using the .split() function of strings? They work the same way
in all these examples, so I was wondering was this because they aren't
supported in python 1.5?
>>> line = 'Hi, my name is Joal.'
>>> f1,f2,f3,f4,f5,f6 = map(lambda x,y:x, line.split(),6*[None])
Joal Heagney is: _____ _____
/\ _ __ __ _ | | _ ___ |
/__\|\ || ||__ |\ || |___|/_\|___] |
/ \ \_||__ ||___| \_|! | | \ \ !
More information about the Python-list