My question is about the split() function in Python. I use the space (" ") character as a separator. Some input are badly formatted and have 2 spaces instead of 1.

Is there an easy non-hackish way to tell split to ignore adjascent repeated spearators?

Example: Consider the file below:
value1 value2
value3  value4
There are two spaces between value3 and value4. It messes up my script because split considers there's an empty element between the two. Isn't there a clean way to solve that?
Can't you use a regex to transform all runs of spaces into a single one?
Something like: "\s+" => " "
And then split.
You could just split() without passing the space.

Otherwise, you could do, [n for n in list if n != '']

P.S.: If this is not the behavior you need, tell me.
xterm wroteYou could just split() without passing the space.
It worked. You rock :)
xterm wroteOtherwise, you could do, [n for n in list if n != '']
Now you're just showing off :P
rahmu wroteNow you're just showing off :P
Not at all!

Python list comprehensions are very powerful. Assume you have a list of people and you want to project this list onto a list that contains their firstnames.
[p.name for p in people]
arithma wroteCan't you use a regex to transform all runs of spaces into a single one?
Something like: "\s+" => " "
And then split.
That's the type of thing I was looking to avoid. See it does what you want, but is hackish. It turns your code into an unreadable unmaintainable puzzle.

In comarison, retracting an argument from the function call seems so much cleaner.
Sometimes, these "hacks" are necessary or essential.
It's actually more explicit as to what is actually is happening, but I do agree, split without the extra argument in this case is cleaner.
Disclaimer: I am no Python guru. I hardly written any python actually.