blueFast
blueFast

Reputation: 44391

ASCII tree, but python does not agree

I have this python script, with a tree for documentation purposes:

# This is the tree, generated with:
#   $ tree -A a
#     a
#     └── tree

if __name__ == '__main__':
    print 'It runs'

If I run it:

  File "xxx.py", line 4
SyntaxError: Non-ASCII character '\xe2' in file xxx.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

I know I can solve that error adding for example:

#coding: utf8

at the top of my script, but I am curious: why does the tree man page say that -A outputs ASCII:

-A     Turn on ANSI line graphics hack when printing the indentation lines.

but python does not recognize the tree as ASCII? Who is wrong? Or am I missing something else?

Upvotes: 0

Views: 169

Answers (1)

dsh
dsh

Reputation: 12214

It is not ASCII. ANSI line grpahics is not the same as ASCII; and ASCII has no line drawing characters. ASCII defines only bytes 0x00 - 0x7F.

Upvotes: 2

Related Questions