whitespace and ?asc()?

Steve Holden sholden at holdenweb.com
Tue Jul 1 23:53:51 EDT 2003


"Ray Tomes" <rtomes at ihug.co.nz> wrote in message
news:3F02086D.9010300 at ihug.co.nz...
> Hi all
>
> I am totally new to python. On the whole I really like the design of the
> language and after just one day may be considered a convert.
>
> I was trying to find out the exact definition of whitespace so I went to
> look at strings.whitespace to find out which chars were whitespace, and
> found 9, 10, 11, 12, 13, 32 which according to my ancient ascii chart are
> TAB, LF, VT, NP, CR, SPACE. Anyone know what NP = 12 is?
>
> Also, in trying to find the ASCII (or is it ANSI) values for characters I
> could not find the reverse function for chr() [in BASIC it is asc()]- can
> someone please tell me what reverses chr()?
>
> 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
>
1: http://www.asciitable.com/

2: ord()

3: import string; print [ord(x) for x in string.whitespace]

You did pretty well to get the output you needed, though!

regards
--
Steve Holden                                  http://www.holdenweb.com/
Python Web Programming                 http://pydish.holdenweb.com/pwp/


>






More information about the Python-list mailing list