On Aug 19, 4:16 pm, Peter Brett <pe...@peter-b.co.uk> wrote: > "digisat...@gmail.com" <digisat...@gmail.com> writes: > > Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) > > [GCC 4.3.3] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> ' test\ttest'.expandtabs(4) > > ' test test' > >>>> 'test \ttest'.expandtabs(4) > > 'test test' > > > 1st example: expect returning 4 spaces between 'test', 3 spaces > > returned > > 2nd example: expect returning 5 spaces between 'test', 4 spaces > > returned > > > Is it a bug or something, please advice. > > Consider where the 4-space tabstops are relative to those strings: > > test test > test test > ^ ^ ^ > > So no, it's not a bug. > > If you just want to replace the tab characters by spaces, use: > > >>> " test\ttest".replace("\t", " ") > ' test test' > >>> "test \ttest".replace("\t", " ") > 'test test' > > HTH, > > Peter > > -- > Peter Brett <pe...@peter-b.co.uk> > Remote Sensing Research Group > Surrey Space Centre
You corrected me for the understanding of tab stop. Great explanation. Thank you so much. -- http://mail.python.org/mailman/listinfo/python-list