473,602 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1953
as*****@gmail.c om 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_f rom_buildvalue['Status']

3. Print value returned from Py_BuildValue, from Python:

print dict_returned_f rom_buildvalue

4. Print value returned from Py_BuildValue, in C

PyObject_Print( obj, stdout, 0);

HTH,
Martin
Jul 21 '05 #2
as*****@gmail.c om 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
4226
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. Is there another way I overlooked? : http://www.python.org/doc/2.3.3/api/arg-parsing.html ParseValue knows "k" for unsigned long, BuildValue doesn't.
2
3114
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 not? Thanks for hints, Torsten.
3
3396
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 contains more rows of data (like
4
1939
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 situation. The user is looking at a page with Text, asp .net controls, and buttons. I want the user to be able to hit a print friendly button and a new window will open, but this new window will have only plain text. Database fields -- and database...
2
3652
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 does not work :-\ Here is my simplified code:
5
2028
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 *args) { .... return Py_BuildValue("(OO)", x, y); } where x & y are both of type PyObject.
4
5400
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 the C code. The C compiler cannot find the required function `Py_BuildValue'. My C code looks like this:
4
2669
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 combo box without a page refresh. I assume that I'll need to query ALL the needed values from the database and store them in an array This can be done in PHP. Drawing
1
2472
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 but a problem is one of the members of the struct is char **, which is not supported by Py_BuildValue. Is there any idiomatic way of mapping char ** to Python?
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.