Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:55:32+00:00 2026-06-14T22:55:32+00:00

I am writing a simple C wrapper for a Python module. What I need

  • 0

I am writing a simple C wrapper for a Python module. What I need to do is create a new PyObject* that represents None. I can’t figure out how to do this. Is there a simple function that will return a PyObject* pointing to None, similar to how PyTuple_New returns a PyObject* pointing to a new tuple or PyString_FromString` returns one pointing to a python string?

Note Is it possible that, when calling a function as below, passing a C NULL will work? example:

//pFunc points to a function with 2 arguments
PyObject *pArgs = PyTuple_New(2);
PyTuple_SetItem(pArgs, 0, PyString_FromString("hello"));
PyTuple_SetItem(pArgs, 1, NULL); // <--- will this create a python object representing None?
pValue = PyObject_CallObject(pFunc, pArgs);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:55:34+00:00Added an answer on June 14, 2026 at 10:55 pm

    According to the documentation, None is a singleton, and is accessible from C code as Py_None.

    PyObject* Py_None The Python None object, denoting lack of value.
    This object has no methods. It needs to be treated just like any other
    object with respect to reference counts.

    Py_RETURN_NONE Properly handle returning Py_None from within a C
    function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a managed wrapper around DirectSound. (It's a simple partial wrapper that solves
I am writing a very simple proxy wrapper for the reddit api so I
I'm writing a very simple and small wrapper around sqlite3, and use sqlite3_get_table() to
I am writing simple site that requires users and profiles to be handled. The
As I'm a novice, I started learning python by writing simple programs using python
I am writing a wrapper to automate some android ADB shell commands via Python
I'm writing a simple wrapper around the Win32 FILETIME structure. boost::datetime has most of
I am having an problem writing unit tests for an simple session wrapper. The
I am writing a simple ruby controller that just needs to respond as a
I'm writing a .NET 4.0 library that should be efficient and simple to use.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.