On Tue, May 18, 2010 at 10:07:56PM -0700, Chris Miller wrote:
> On Tue, May 18, 2010 at 7:45 PM, Jeremy Leonard <[email protected]> wrote:
> > I am in the process of teaching myself python 3 and  I have been able
> > to change vi so that tabs are 4 characters instead of 8.  What I'm
> > having a hard time with is figuring out how to change the output from
> > a print() statement, within python script to a bash terminal screen,
> > so that a '\t' character outputs 4 characters instead of 8.
> >
> > I've tried looking at the documentation for python to see if there is
> > a way of modifying how the print() statement works, but I haven't
> > found anything that route.  I've also tried to find a way of possibly
> > adding something to the .bashrc or .bash_profile files to change this,
> > but so far no luck. Any help would be greatly appreciated.
> 
> This is determined by the terminal renderer.  The default is 8.  The
> easiest way is to configure your editor for "soft tabs," where it uses
> spaces instead of tabs, but then treats a set of four spaces like a
> tab character.  So:
> 
>     ^W
> = (nil)
> 
> I didn't think Python supported tabs; the few times I've dabbled in
> it, it's always screamed bloody murder if I use tabs.  I'm a Ruby guy
> myself, so I can't help you much beyond knowing what editors do and
> don't.  Maybe some real Python guys will be of more help than my
> simple "it's a problem with your editor" statement?
> 
> -- 
> Registered Linux Addict #431495
> For Faith and Family! | John 3:16!
> http://www.fsdev.net/
> 
> -- 
> You received this message because you are subscribed to the Linux Users Group.
> To post a message, send email to [email protected]
> To unsubscribe, send email to [email protected]
> For more options, visit our group at 
> http://groups.google.com/group/linuxusersgroup
Python does allow tabs, you just need to be consistent about what your
tab level is made up of (i.e. if you use a tab to enter a tab level, the
next line can't use spaces). I find the whitespace dependency is fine as
long as you don't switch editors, and don't let anyone else touch your
code :) (different editors have different ideas about how to help you
indent).

As for bash using a 4-space tabstop, 'setterm -regtabs 4' should do it.

Attachment: pgph8QYlauv36.pgp
Description: PGP signature

Reply via email to