string objects...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • google account

    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.printabl e -
    string.whitespa ce but that doesn't seem to work like string.letters +
    string.numbers. ..


    TIA


    Googleboy
  • Lukasz Pankowski

    #2
    Re: string objects...

    mynews44@yahoo. com (google account) writes:
    [color=blue]
    > 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.printabl e -
    > string.whitespa ce but that doesn't seem to work like string.letters +
    > string.numbers. ..
    >[/color]

    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:
    [color=blue][color=green][color=darkred]
    >>> import string
    >>> ''.join([c for c in string.printabl e if c not in string.whitespa ce])[/color][/color][/color]
    '0123456789abcd efghijklmnopqrs tuvwxyzABCDEFGH IJKLMNOPQRSTUVW XYZ!"#$%&\'()*+ ,-./:;<=>?@[\\]^_`{|}~'

    --

    =*= Lukasz Pankowski =*=

    Comment

    Working...