469,281 Members | 2,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

string objects...

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...
TIA
Googleboy
Jul 18 '05 #1
1 1727
my******@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])

'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM NOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'

--

=*= Lukasz Pankowski =*=
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by David zhu | last post: by
8 posts views Thread by Lee Jackson | last post: by
17 posts views Thread by Chad Myers | last post: by
32 posts views Thread by tshad | last post: by
53 posts views Thread by Jeff | last post: by
34 posts views Thread by Larry Hastings | last post: by
41 posts views Thread by nospam | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.