473,378 Members | 1,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

print values from Py_BuildValue

Hello,

How do i print values returned by Py_BuildValue in Linux?

PyObject *obj = Py_BuildValue("{s:i}", "Status", status);

I need to print the Status value here

-Thanks,
Ashton

Jul 21 '05 #1
2 1941
as*****@gmail.com wrote:
How do i print values returned by Py_BuildValue in Linux?

PyObject *obj = Py_BuildValue("{s:i}", "Status", status);

I need to print the Status value here


I'm confused. You say you need to print the Status value here,
but then you also say you want to print the value returned
from Py_BuildValue, which is *not* the status value, but
a dictionary.

You also don't say whether you want to print this using
Python code or C code, so this gives a total of four interpretations
of your question:

1. Print status from C, on Linux:

printf("The status is %d\n", status);

2. Print status from Python:

print dict_returned_from_buildvalue['Status']

3. Print value returned from Py_BuildValue, from Python:

print dict_returned_from_buildvalue

4. Print value returned from Py_BuildValue, in C

PyObject_Print(obj, stdout, 0);

HTH,
Martin
Jul 21 '05 #2
as*****@gmail.com wrote:
Hello,

How do i print values returned by Py_BuildValue in Linux?
1. The same way as you would "in" any other operating system.
2. With difficulty.
3. If you must print something from C, print the C components (no
difficulty).
4. If you are interested in checking what you have created, return the
value to the Python caller, and print from there (no difficulty).
5. However if you have a debugging problem, read on ...

PyObject *obj = Py_BuildValue("{s:i}", "Status", status);

I need to print the Status value here


What is the 'Status' value?
'"Status"' and 'status' are C expressions which you should be able to
print using printf.
Do you mean 'obj'?
Why do you think you need to print something here? Are you asking
because you are getting a strange exception?
Have you tested the value returned by Py_BuildValue -- like this:
/* the following line is written to clarify intent,
not as an example of good coding style :-) */
if (obj == NULL) goto free_resources_and_return_NULL;

Are you extending or embedding?
Is this your first attempt?
Have you considered using Pyrex? It does almost of the hard work for you.

HTH,
John
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christian Vogel | last post by:
Hi comp.lang.python readers, are there routines to create a Python integer from unsigned C-integers? I only could find Py_BuildValue and PyInt_FromLong which both only use signed c-integers....
2
by: Torsten Mohr | last post by:
Hi, when i write an extension module in C and return a Py_Object* that i've built with Py_BuildValue, do i need to use Py_INCREF on that before i return it to python from my extension module or...
3
by: babu | last post by:
Hello All, How are you? I am facing an issue to print all the form control values (including datagrid values). Is there a way to print all the control values in VB.NET. If the grid...
4
by: Matt Mercer | last post by:
Hi, I have a asp .net/VB web app that does the typical submitting and retrieving from a SQL database. I am lost as to how I should create a print friendly page for the data. Here is the...
2
by: Martin Kulas | last post by:
Hallo! I have a problem with Py_BuildValue: I want to convert an unsigned int to a PyObject *. http://docs.python.org/api/arg-parsing.html says that I can use "I" as a format string. But it...
5
by: Christian Meesters | last post by:
Hi I'm having trouble with Py_BuildValue. I was able to pinpoint the following statement as the one causing a seg. fault with my script: static PyObject * funcname(PyObject *self, PyObject...
4
by: spectrumdt | last post by:
Hello. I am trying to extend Python with some C code. I made a trivial "Hello World" program in C that I am trying to wrap in "boilerplate" for inclusion in a Python program. But I can't compile...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
1
by: js | last post by:
Hi, I'm writing a wrapper module of C API. To make a C struct data avaiable to Python, I need to map C struct into a PyObject. I'm thinking that I use a tuple or dict to represent the struct...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.