Thanks, John.  That's exactly what I was looking for!

John Machin wrote:
> Putty wrote:
> > I'm porting a program a friend wrote in C over to Python and I've run
> > into a little hang-up.  The C program writes characters out to a file.
> > I'm 99% sure that a conversion is going on here as well.  I know for a
> > fact that it's taking a number and turning it into a character.
>
> C is a low-level language -- a character *is* a number :-)
>
> >
> > So what kind of call can I make to do it in Python?
>
> *Guessing* that you mean e.g. fputc(97, f) writes the character 'a' to
> the file whose handle is f ...
>
> In Python the more-or-less literal translation (ignoring the fputc
> return value) would be f.write(chr(97))
>
> Note:
> |>>> ord('a')
> 97
> |>>> chr(97)
> 'a'
>
> HTH -- if not, show us (relevant parts of) the actual source that you
> are porting.
> 
> Cheers,
> John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to