by calroc · 12y ago · 0 comments
>>> from string import ascii_letters
>>> ors = ['|'] * (len(ascii_letters) * 2 - 1)
>>> ors[::2] = ascii_letters
>>> ''.join(ors)
'a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z'
(Obviously, in this example '|'.join(ascii_letters) would suffice, but if the objects weren't strings...) from string import ascii_letters
'|'.join( ascii_letters )
(I also like list slicing... but only when necessary.) '|'.join(str(x) for x in y) # or
'|'.join(map(str, y))Aw, heck, code speaks louder than words:
https://github.com/PhoenixBureau/PigeonComputer/blob/master/...