putchar(8)

G

gervaz

Hi all, is there in python the equivalent of the C function int putchar
(int c)? I need to print putchar(8).

Thanks, Mattia
 
D

Dave Angel

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
 
D

Dennis Lee Bieber

Note that print is going to also put out a new-line ending...

To JUST put out the single byte will require using the plain file
I/O method:

sys.stdout.write("\x08")
 
D

Dave Angel

Dave said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top