string objects...

Lukasz Pankowski lupan at zamek.gda.pl
Fri Sep 19 06:45:35 EDT 2003


mynews44 at yahoo.com (google account) writes:

> I know that string.letters and string.digits are all the letters and
> numbers, is there a string.????  that is a subset of all the ascii
> characters that are available on a US English Keyboard without going
> to special characters (like ß or ¿)
>
> I couldnt see anything that was explaining this stuff on the
> python.org site.
>
> I think what I want is soemthing like string.printable -
> string.whitespace but that doesn't seem to work like string.letters +
> string.numbers...
>

Minus does not work on string, as there is now obvious meaning of
this: cut from the end, or a set like minus you would be happy this
time

You may use list comprehension to filter out all whitespace from
printable and than join the list with empty separator:

>>> import string
>>> ''.join([c for c in string.printable if c not in string.whitespace])
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'

-- 

=*= Lukasz Pankowski =*=




More information about the Python-list mailing list