[docs] Problem with Tab

Julien Palard julien at palard.fr
Fri Mar 29 04:35:06 EDT 2019


Hi Zxenderock,

I'm trying to reproduce your issue but for the moment I can't, here what's I tried, please try to follow on your computer so we could find where the bug really lies:

- Open IDLE
- type print("a\tb\tc")
- See "a        b        c" with my eyes, can't tell if it's spaces or tabs so like you I'm copying it
- On a bash, I type "cat -A"
- I paste the previously copied string, type the enter key, and I see: a^Ib^Ic$

I conclude that what I copied is in fact the letter "a" followed by a single horizontal tab followed by the letter "b" and so on.

Few questions and answers:

# Why did I used cat -A instead of notepad?

- Because I do *not* trust notepad not modifying what I past to it
- Because I'm using Debian, so I do *not* have notepad

# What is this cat -A thing?

cat is in fact aimed at concatenating files, but with the -A flag (from the manual: -A, --show-all  equivalent to -vET) it's a nice way to get non-printable character nicely represented.

# How can I try your cat -A thing on Windows to tell if it's notepad that messed up with the tabs?

You should try with "git bash", I bet it comes with cat: https://gitforwindows.org/

# How did you interpret the mess out of cat -A?

The $ at the end means "end of line", no magic here it's from the cat manual: "-E, --show-ends   display $ at end of each line", and -A implies -E.
(There was *no* newline out of what I copied, it's my typing the enter key after pasting so cat ingest the line.)

The ^I thing is bit harder to understand at first, but fortunately it's in the manual page too: "-T, --show-tabs display TAB characters as ^I", and -A also implies -T

# Is there a better way to check than cat -A?

Yes I should have used hexdump, but I don't think git bash comes with hexdump, and I prefer a way you can reproduce on your machine. Using hexdump it looks like this:

    $ xclip -o | hexdump -C
    00000000  61 09 62 09 63                                    |a.b.c|
    00000005

(xclip is a way to get the content of the copy/paste buffer, I don't think you'll have it using git bash neither)
As you can see, a b and c letters are only separated by a single 09 character. and according to the `man ascii` manual page, it's an horizontal tab: `09    HT  '\t' (horizontal tab).

So for me, IDLE is doing the right thing, and I bet your notepad is messing with the stirng while you're pasting it, which I can't verify here.

Bests,
--
Julien Palard
https://mdk.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190329/026401d8/attachment-0001.html>


More information about the docs mailing list