News for hackers. Stuff that matters.
Re:Python Idioms [pdf] by beambot on Thursday January 30, 2014 @02:56PM (#7152956)
Not gonna lie... your snippet made me say "WTF?" Why not just do:

  from string import ascii_letters
  '|'.join( ascii_letters )
(I also like list slicing... but only when necessary.)
Re:Python Idioms [pdf] by calroc on Thursday January 30, 2014 @03:06PM (#7153013)
Yeah, I realized after posting it. (See edit.) The original code was using non-string objects. I basically come up with this to get the same behavior as str.join(). ;-)
Re:Python Idioms [pdf] by jerf on Thursday January 30, 2014 @03:27PM (#7153142)

    '|'.join(str(x) for x in y) # or
    '|'.join(map(str, y))
Re:Python Idioms [pdf] by calroc on Thursday January 30, 2014 @05:18PM (#7153726)
The original use for that code was to build a list of parsing objects to create a single parsing object that was the OR'ing of the basic ones.

Aw, heck, code speaks louder than words:

https://github.com/PhoenixBureau/PigeonComputer/blob/master/...

Re:Python Idioms [pdf] by jerf on Thursday January 30, 2014 @09:25PM (#7154871)

    intersperseM or $ map chartok whitespace
Oh... wait... sorry... wrong language.