/ Published in: Python
                    
                                        
warning: snipplr tends to escape the quotes and slashes, causing this snippet to fail when pasted verbatim.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
def wrap_text(txt, col = 80):
import re
re.sub("/(.{1,#{col}})( +|$n?)|(.{1,#{col}})/", "\1\3n", txt)
# warning: snipplr tends to escape the quotes and slashes, causing this
# snippet to fail when pasted in.
return txt
Comments
 Subscribe to comments
                    Subscribe to comments
                
                