Why ELIF?

John Machin sjmachin at lexicon.net
Sun Oct 11 21:34:51 EDT 2009


MRAB <python <at> mrabarnett.plus.com> writes:

> 
> Simon Forman wrote:
> [snip]
> > 
> > I'll often do that this way:
> > 
> > args = re.split('\s', line)
> 
> This has the same result, but is shorter and quicker:
> 
> args = line.split()
> 

HUH?

Shorter and quicker, yes, but provides much better functionality; it's NOT the
same result:

 >>> line = '   aaa   bbb   ccc   '
 >>> import re
 >>> re.split('\s', line)
 ['', '', '', 'aaa', '', '', 'bbb', '', '', 'ccc', '', '', '']
 >>> line.split()
 ['aaa', 'bbb', 'ccc']
 >>>





More information about the Python-list mailing list