Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way around coding in Python without the tab, indent & whitespace criteria?

Tags:

python

I want to start using Python for small projects but the fact that a misplaced tab or indent can throw a compile error is really getting on my nerves. Is there some type of setting to turn this off?

I'm currently using NotePad++. Is there maybe an IDE that would take care of the tabs and indenting?

like image 314
Donny V. Avatar asked Sep 15 '08 13:09

Donny V.


People also ask

IS indenting optional in Python?

Python Indentation Rules The first line of python code cannot have an indentation. Indentation is mandatory in python to define the blocks of statements. The number of spaces must be uniform in a block of code. It is preferred to use whitespaces instead of tabs to indent in python.

Does Python need indentation matter?

Indentation refers to the spaces at the beginning of a code line. Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. Python uses indentation to indicate a block of code.

Does Python care about indentation?

Indentation is essential in Python; it replaces curly braces, semi-colons, etc. in C-like syntax.


2 Answers

The answer is no.

At least, not until something like the following is implemented:

from __future__ import braces
like image 185
Chris Calloway Avatar answered Oct 25 '22 19:10

Chris Calloway


No. Indentation-as-grammar is an integral part of the Python language, for better and worse.

like image 35
Asaf Bartov Avatar answered Oct 25 '22 19:10

Asaf Bartov