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

  • Home
  • SEARCH
  • 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 944609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:37:12+00:00 2026-05-15T22:37:12+00:00

I found this nice example of a Python C Module, where a single integer

  • 0

I found this nice example of a Python C Module, where a single integer is passed along as the only argument. How can I instead pass a python list as argument?

  • 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-05-15T22:37:12+00:00Added an answer on May 15, 2026 at 10:37 pm

    From http://code.activestate.com/lists/python-list/31841/:

    ...
    char * tok;         /* delimiter tokens for strtok */
    int cols;           /* number of cols to parse, from the left */
    
    int numLines;       /* how many lines we passed for parsing */
    char * line;        /* pointer to the line as a string */
    char * token;       /* token parsed by strtok */
    
    PyObject * listObj; /* the list of strings */
    PyObject * strObj;  /* one string in the list */
    
    /* the O! parses for a Python object (listObj) checked
       to be of type PyList_Type */
    if (! PyArg_ParseTuple( args, "O!is", &PyList_Type, &listObj, 
               &cols, &tok )) return NULL;
    
    /* get the number of lines passed to us */
    numLines = PyList_Size(listObj);
    
    /* should raise an error here. */
    if (numLines < 0)   return NULL; /* Not a list */
    

    …

    /* iterate over items of the list, grabbing strings, and parsing
       for numbers */
    for (i=0; i<numLines; i++){
    
    /* grab the string object from the next element of the list */
    strObj = PyList_GetItem(listObj, i); /* Can't fail */
    
    /* make it a string */
    line = PyString_AsString( strObj );
    
    /* now do the parsing */
    

    See Parsing arguments and building values

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

Sidebar

Related Questions

I found this example: http://www.yaml.org/YAML_for_ruby.html#extending_kernel::hash It's nice to see how easy YAML can serialize
Following this nice example I found, I was trying to create a function that
I found a nice example on how to use AJAX in jQuery at this
I found this nice example of doing paging in SQL Server, however, I need
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
Found this is some example CSS I was reading and I'm having a hard
I see lots of php libraries that can parse html. A nice example is
By using Google I have found some nice snippets of example code for using
I have found a nice example how to find the center point of a
I found nice little one example of Scala today. Something like: (1 to 100)

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.