Edward Elliott wrote: >Dave Hansen wrote: > > >I fail to see why less 'will work' but cat 'doesn't always work'. > The distinction is not in the choice of program, but in the way it is being used...
>The net >effect of both is the same. Unless you're in some weird place that pipes >aren't allowed, these should be equivalent: > >cat file |sed 's/\t/ /g' |less >less -x4 file > > Nope. To demonstrate, I will use "T" to represent tab characters and "S" to represent spaces (I think this will be a lot easier to read): In a properly formatting program, with tabstops at intervals of 4: A= """ SSTSTdefSspam(self,Sfoo): STTSSSSbarS=S1/foo TTSTreturnSbar """ and B = """ TTdefSspam(self,Sfoo): SSSSSSSSSSSSbarS=S1/foo TTTreturnSbar """ should render exactly the same (i.e. like the following): A=B= """ def spam(self, foo): bar = 1/foo return bar """ However, if we have tabstop set to 8 (the usual default), then they will render differently: A= """ def spam(self, foo): bar = 1/foo return bar """ B= """ def spam(self, foo): bar = 1/foo return bar """ (both are syntax errors, of course). Presumeably, the "x" option to less will correctly handle tabs (I didn't know about that -- thanks, BTW), but your sed substitution doesn't "jump to the next tabstop" when it hits a tab, it always adds a fixed number of spaces. So it mangles the code too: A= """ def spam(self, foo): bar = 1/foo return bar """ B= """ def spam(self, foo): bar = 1/foo return bar """ >Now if you're talking about the conversion altering the data's semantics, >that's a separate issue that has nothing to do with unix utilities and >everything to do with the file formatting. In that case, I'll simply refer >you to the rest of this thread for discussion. > > Now, of course, the data I provide is nasty, mean, poorly-formatted data, abhorable by space-zealots and tab-libertines alike (;-)), but the point is, unless you have set up your editor to syntax color spaces and tabs differently, you won't see the difference in the original editor. Cheers, Terry -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list