Writing a CPython extension - calling another sibbling method ?

R.Wieser address at not.available
Wed Nov 20 04:59:15 EST 2019


Dennis,

> So... extract the original args, then build a new args object with your
> added argument, then call your new function with that...

I wanted to respond that prepending a string to an existing argument sounds 
quite a bit easier than what you are describing, but than I realized that I 
just flatout assumed that the origional "args" would be a string too ..

Thanks for the links.   And yes, thats one of the six related pages I've 
saved.    I blame me being focussed on calling another method, (pretty-much) 
ignoring the arguments til after I found it (arguments without being able to 
call would have had a zero value to me).   Looking back I can now see their 
value.

> {Personally, I still think you are looking for a solution to a problem
> that doesn't exist.

I for my part still think that my "lets dig into it" has been worthwhile to 
me - much more than just grabbing another extension.    I've learned a few 
things along the way, which is really all that matters to me.

> The proper way to handle this is to NOT hard-code any pin numbers
> in your module, but instead provide an initialization/setup function which
> the end-user calls, passing in pin numbers in their preferred scheme.

Absolutily.   But instead of requiring the (noobie) user to provide those I 
tend to make that optional by using defaults.

> they provided the pins in that scheme and your code doesn't
> have to worry about it.

Yep, thats one way to solve the problem. :-)

Regards,
Rudy Wieser




More information about the Python-list mailing list