News for hackers. Stuff that matters.
Re:Anti-Patterns in Python Programming by klibertp on Wednesday July 09, 2014 @08:50AM (#8009338)
It's not weird, it's wrong:

    In [1]: "a    string     r".split(" ")
    Out[1]: ['a', '', '', '', 'string', '', '', '', '', 'r']

    In [2]: "a    string     r".split()
    Out[2]: ['a', 'string', 'r']
Re:Anti-Patterns in Python Programming by glomph on Wednesday July 09, 2014 @09:27AM (#8009484)
In their case though that wouldn't have been a problem as each word was split on a single space.
Re:Anti-Patterns in Python Programming by hcarvalhoalves on Wednesday July 09, 2014 @03:53PM (#8011865)
Split without argument is equivalent to:

    >>> filter(None, " quick   hack for  split".split(" "))
    ['quick', 'hack', 'for', 'split']
Re:Anti-Patterns in Python Programming by klibertp on Wednesday July 09, 2014 @04:22PM (#8012038)
Yeah, or re.split(r'\s+', ...), or something - the issue here is that you need to know about this.

From the comment a few levels up I understood that the code which used the str.split with " " argument didn't signify that someone who written it knew about its semantics. If he did and it was really what was intended then ofc it's completely ok, but if not, it can easily lead to bugs.

For example, if the user is required to input several ints separated with whitespace, this:

    map(int, input_str.split())
will rise only in expected cases, while this:

    map(int, input_str.split(" "))
can lead to rejecting correct input just because someone pressed space twice. It's very frustrating for the user, too, because whitespace are hard to spot visually.

So, I don't know if this qualifies as antipattern, but I think if I saw .split(" ") instead of .split() in the code I'd at the very least expect the comment explaining why it's used.