File traversing
Chris Angelico
rosuav at gmail.com
Tue Apr 17 10:36:03 EDT 2012
On Wed, Apr 18, 2012 at 12:31 AM, Nibin V M <nibinvm at gmail.com> wrote:
> # python test.py
> File "test.py", line 1
> with open('/etc/trueuserowners') as res_own_file:
> ^
> IndentationError: unexpected indent
Make sure your first code line is flush left. Since indentation
indicates block structure (and not scoping, as it does in C-like
languages), Python refuses to allow it anywhere other than inside
something that can make use of it. If you're copying and pasting a
huge lot of code from somewhere and it's all indented a minimum of a
couple of spaces, the simplest solution may be to add a line at the
top saying "if True:", thus making your whole program into a massive
block if, which Python will happily accept.
ChrisA
More information about the Python-list
mailing list