wood burning stoves 2.0*
The moose likes Jython/Python and the fly likes How to indent Python file without using TAB key? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "How to indent Python file without using TAB key?" Watch "How to indent Python file without using TAB key?" New topic
Author

How to indent Python file without using TAB key?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
I'm using Python in GAE and I noticed that if I use TAB when writing the code it generates an error when trying to run it. So, I had to use Notepad++ checking where TAB characters were and substitute them by blank spaces.
I'd like to know a better way to indent the code... does anyone have already had this problem?


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1774
    
  14

Most language-aware editors allow you to specify that you want tabs to be converted automatically to e.g. 2 or 3 spaces as you type. Notepad++ almost certainly supports this so have a look in the preferences/settings. Alternatively you could use a free Python editor like Pyscripter or Spyder. If your editor has Python-specific settings, it should recognise the current tab level and indent each new line automatically.

Edit: Here's how you set the tab size and/or tell Notepad++ to use spaces for tabs: http://npp-community.tuxfamily.org/documentation/notepad-user-manual/settings/preferences#Language_Menu


No more Blub for me, thank you, Vicar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to indent Python file without using TAB key?