Looking for Form Feeds

Fredrik Lundh fredrik at pythonware.com
Mon Jan 24 18:05:02 EST 2005


Terry Hancock wrote:

>> I also tried to create a ^M^L (typed in as <ctrl>Q M <ctrlQ> L) but that
>> gives me a syntax error when I try to run the program (re does not like
>> the control characters, I guess).  Is it possible for me to pull out the
>> formfeeds in a straightforward manner?
>
> I suspect you should convert that to hexadecimal codes: '\x0c\x0b'
> (at least I *think* those are the characters you mean, I'm not really
> familiar with the ^X notation).

you're off by one:

    >>> hex(ord("M") - 64)
    '\0xd'
    >>> hex(ord("L") - 64)
    '\0xc'

    >>> chr(ord("M") - 64)
    '\r'
    >>> chr(ord("L") - 64)
    '\x0c'
    >>> "\f"
    '\x0c'

</F> 






More information about the Python-list mailing list