See if you can determine what this does:
def cbk(match, nb = [0] ): if len(match.group())==len(nb): nb[-1] += 1 elif len(match.group())>len(nb): nb.append(1) else: nb[:] = nb[0:len(match.group())] nb[-1] += 1 return match.group()+' '+('.'.join(map(str,nb))) str = re.compile('^(#+)',re.MULTILINE).sub(cbk,str)
## #
## 0.1 # 1
See if you can determine what this does: