Re: whitespace and ?asc()?

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

  1. 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
    #1
    1. Advertising

  2. Steven Taschuk

    Dan Bishop Guest

    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
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    1
    Views:
    579
  2. Alan Silver
    Replies:
    9
    Views:
    15,670
    Alan Silver
    Jun 7, 2005
  3. Henri =?ISO-8859-15?Q?Schom=E4cker?=
    Replies:
    1
    Views:
    295
    Henri =?ISO-8859-15?Q?Schom=E4cker?=
    Dec 17, 2005
  4. Jimakos Bilakis
    Replies:
    9
    Views:
    281
    Ben Pope
    Mar 27, 2006
  5. Aspire Software Consultancy

    Salesforce.com Top Buzz ----ASC Promoting Salesforce.com in India

    Aspire Software Consultancy, Mar 15, 2011, in forum: C Programming
    Replies:
    0
    Views:
    318
    Aspire Software Consultancy
    Mar 15, 2011
Loading...

Share This Page