# Re: whitespace and ?asc()?

Discussion in 'Python' started by Steven Taschuk, Jul 2, 2003.

1. ### Steven TaschukGuest

Quoth Ray Tomes:
[...]
> Also, in trying to find the ASCII (or is it ANSI) values for characters I

The only thing nobody else commented on:

The character code standard is ASCII (American Standard Code for
Information Interchange, if memory serves), but it is an ANSI
standard (the American National Standards Institute). (There's an
equivalent ISO standard, I think... ISO 646?)

In some communities, "ANSI" is used metonymously to refer to some
specific ANSI standard for terminal control codes, I think. But
this has nothing to do with ASCII.

> I had to do this yucky thing to decode whitespace ...
>
> import string
> x=string.whitespace
> for b in x:
> for i in range(256):
> if chr(i) == b:
> print i

Note also that at the interpreter prompt you can (some of) those
ASCII codes in hex just by looking at the value of the string:

\$ python
...
>>> import string
>>> string.whitespace

'\t\n\x0b\x0c\r '

If your ASCII chart doesn't have hex, continue with

>>> 0x0b, 0x0c

(11, 12)

to obtain the decimal values.

--
Steven Taschuk
"Our analysis begins with two outrageous benchmarks."
-- "Implementation strategies for continuations", Clinger et al.

Steven Taschuk, Jul 2, 2003

2. ### Dan BishopGuest

Steven Taschuk <> wrote in message news:<>...
[snip]
> Note also that at the interpreter prompt you can (some of) those
> ASCII codes in hex just by looking at the value of the string:
>
> \$ python
> ...
> >>> import string
> >>> string.whitespace

> '\t\n\x0b\x0c\r '
>
> If your ASCII chart doesn't have hex, continue with
>
> >>> 0x0b, 0x0c

> (11, 12)
>
> to obtain the decimal values.

FYI,

'\x0b' == '\v' (vertical tab)
'\x0c' == '\f' (form feed)

Dan Bishop, Jul 3, 2003