I feel stoopid ... this code is to verbose

Christophe Delord christophe.delord at free.fr
Fri Jun 14 18:49:08 CEST 2002


Here is a 3-liner ;-)


> > I just cannot seem to find the nice 3-liner I expected from the 
> > beginning. Has anybody got a better solution ? I thought somebody might 
> > find it a fun exercise. Well I have...

def stringSlicer(st, chunkSize=3):
	def slc(st): return st and slc(st[:-chunkSize])+[st[-chunkSize:]] or []
	return ".".join(slc(st))




-- 

(o_   Christophe Delord                   _o)
//\   http://christophe.delord.free.fr/   /\\
V_/_  mailto:christophe.delord at free.fr   _\_V



More information about the Python-list mailing list