By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Extention String returning

P: n/a
I have been writing a program that is designed to return an 8 byte
string from C to Python. Occasionally one or more of these bytes will
be null, but the size of it will always be known. How can I write an
extention module that will return the correct bytes, and not just until
the null? I would think there would be a fairly easy way to do this,
but, well... Thanks!

Oct 24 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I think that you want to use
return PyString_FromStringAndSize(buf, 8);

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDXSwxJd01MZaTXX0RAraIAJ9IZ+pa8oWUC3HTKkKG3i hHoiw5ZACdGqzP
9EietMnOAAsfWkS3SzzA4l4=
=QTYP
-----END PGP SIGNATURE-----

Oct 24 '05 #2

P: n/a
"Tuvas" wrote:
I have been writing a program that is designed to return an 8 byte
string from C to Python. Occasionally one or more of these bytes will
be null, but the size of it will always be known. How can I write an
extention module that will return the correct bytes, and not just until
the null? I would think there would be a fairly easy way to do this,
but, well... Thanks!


return PyString_FromStringAndSize(buffer, bytes);

or

return Py_BuildValue("s#", buffer, bytes);

</F>

Oct 24 '05 #3

P: n/a
Thanks for the help!

Oct 24 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.