Yeah you're right. http://stackoverflow.com/questions/2186919/getting-correct-string-length-in-python-for-strings-with-ansi-color-codes
On Mon, Nov 21, 2011 at 8:12 PM, Jeff Forcier <[email protected]> wrote: > On Mon, Nov 21, 2011 at 3:40 PM, Ahsan Rabbani <[email protected]> wrote: > > I've noticed that when printing strings that are wrapped in color > functions > > it screws up the string formatting. > > My guess would be that it has something to do with the non-printing > ANSI color escape codes that the color functions add. They're likely > "counting" as individual characters from the perspective of Python's > string formatter when it does the left-justify. > > Offhand workarounds (caveat: I don't do a ton of string manip these > days...): manually calculating how the justification should occur > (based on the string before it is colorized) and adding the extra > spaces yourself; or doing a substitution (i.e. justify, then take the > result and substitute the original string for the colorized string.) > > Hope that helps, > Jeff > > -- > Jeff Forcier > Unix sysadmin; Python/Ruby engineer > http://bitprophet.org >
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
