• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to indent Python file without using TAB key?

 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic