putchar(8)

mattia gervaz at gmail.com
Sat Oct 17 06:53:11 EDT 2009


Il Sat, 17 Oct 2009 06:48:10 -0400, Dave Angel ha scritto:

> Dave Angel wrote:
>>
>> Jason Tackaberry wrote:
>>> On Fri, 2009-10-16 at 12:01 -0700, gervaz wrote:
>>>  
>>>> Hi all, is there in python the equivalent of the C function int
>>>> putchar (int c)? I need to print putchar(8).
>>>>     
>>>>     
>>>
>>>>>> print '\x08'
>>>>>>         
>>>>>>         
>>> or:
>>>
>>>
>>>>>> print chr(8)
>>>>>>         
>>>>>>         
>>>
>>>
>>>
>> If I recall correctly, putchar() takes an int value 0-255 and outputs a
>> single character to stdout.  So the equivalent would be:
>>
>> sys.stdout.write(char(c))
>>
>> print does other stuff, which you presumably do not want.
>>
>> DaveA
>>
>>
>>
> Oops.  Instead of char(), I meant to type chr().
> 
> 
> sys.stdout.write(chr(c))
> 
> chr() is a built-in that converts an integer to a single character.
> 
> DaveA

Yes, noticed ;-)



More information about the Python-list mailing list