Page 1 of 1
8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 1:15 pm
by fluffy
qotd: Has anyone here used libPython to allow calling Python code from C? I feel like I'm banging my head against the wall in trying to do basic, vital things, like resolving function objects. The only useful stuff I find online is going the other way around (calling C from Python) which isn't what I need.
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 1:50 pm
by HeuristicsInc
no, but i did have a really similar problem trying to find info on calling java code from c++.
i did eventually figure that one out.
-bill
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 1:54 pm
by jast
If it helps... I hate Python and never use it.
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 1:54 pm
by fluffy
I used to think JNI was horrific, and then I had to use libpython. I don't hate JNI as much anymore.
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 3:45 pm
by Caravan Ray
I used to be licenced to handle both pythons and venomous snakes in Queensland. I would remove them from people's houses and release them in the bush. Pythons are easy to catch - but brown snakes are really scary.
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 4:05 pm
by fluffy
I figured it out. It turns out that while all the examples use PyModule_AddModule(), I wanted to use PyModule_ImportModule(), which I would have known if I'd bothered to read the documentation for PyModule_AddModule() but I don't know Python and the documentation seems to assume some sort of pathologically intimate familiarity with not only the language but the source code of the interpreter itself.
Re: 8-12-09 a snake in the pants
Posted: Wed Aug 12, 2009 4:51 pm
by Ross
I have no idea what you are talking about - except the part caravan ray said.
Re: 8-12-09 a snake in the pants
Posted: Thu Aug 13, 2009 6:26 am
by mrbeany
Personally, I really like Python. Sure the syntax is a bit odd compared to some (the whole white-space has meaning thing) but when you accept that all practical coding styles either highly recommend or outright require some sort of spacing consensus it isn't nearly that bad.
I'm planning to teach my daughter Python as her first computer language. My wife jokes that it'll make her a Parselmouth.
I've never needed to call it from another language. Last time I even thought about that, I decided it was a better idea to just do the whole thing in Python.
I, however, abhor Ruby. Everyone has certain things that they just can't stomach when it comes to languages.
Back in the day, I did some testing on a Java runtime environment. That whole process caused me to hate Java a lot, but in the long term even back then it was less than I currently hate Ruby. And now, shoot, I practically don't hate Java at all.
Re: 8-12-09 a snake in the pants
Posted: Thu Aug 13, 2009 8:00 am
by fluffy
Well yeah, Python does seem like a rather good "my first language" language. Certainly better than BASIC, which is what I grew up with. And it's a great extension/scripting language for a number of reasons, which is why we're using it. But we can't just do the whole thing in Python for reasons I won't get into.
Now that I have module loading, symbol resolution, and method invocation working, I'm satisfied and not hating the library so much as the crappy documentation. The main thing I hate about it is just the SDK docs, since it has a lack of useful example code (and for some reason it's really hard to find any simple do-just-this-one-thing code online) which aren't very easy to consult unless you know exactly what you're looking for, which requires a lot more intimacy with the language's conceptual model than I've ever had any reason to get.
Many years ago I played with libtcl for similar purposes and found it extremely easy and straightforward to use, but Tcl just isn't a popular enough language (mostly because of a bad reputation from Tcl/Tk, but also because its standard library is a bit cumbersome to work with) even though conceptually Tcl and Python actually aren't all that different, from an underlying semantics/design standpoint anyway, although the big advantage Python has is that nearly everything's a dictionary (which makes OO stuff completely natural), while in Tcl everything's a list, so in Tcl you end up having a lot of "marshalling" mechanisms which treat objects as opaque tokens which have to be accessed through external functions.
Re: 8-12-09 a snake in the pants
Posted: Thu Aug 13, 2009 10:25 am
by ujnhunter
I thought Ebonics was the most hated language?
Re: 8-12-09 a snake in the pants
Posted: Fri Aug 14, 2009 2:39 pm
by Billy's Little Trip
Has anyone here used libPython to allow calling Python code from C?
I invented it, ask me anything.
Please ask in the form of a yes or no question.
Please note, there is a 50% error allowance in my answers.
Ok, fire when ready, grizzly.

Re: 8-12-09 a snake in the pants
Posted: Fri Aug 14, 2009 2:43 pm
by fluffy
Hey! Where ya been?
(Also I am pretty sure your name is not Guido.)
Re: 8-12-09 a snake in the pants
Posted: Fri Aug 14, 2009 3:13 pm
by Billy's Little Trip
fluffy wrote:Hey! Where ya been?
(Also I am pretty sure your name is not Guido.)
That's because you don't have ESPN (extrasensory perception knowledge...the K is silent)
Business finally started getting better. I couldn't sell a gold fish pond towards the end of 08, and now I'm closing huge projects. YAY!!! Jon will be happy to know that he campaigned for the right guy, lol.
I need to rock again. I miss all you freaks, geeks and alcoholics.

Re: 8-12-09 a snake in the pants
Posted: Sat Aug 15, 2009 7:07 am
by JonPorobil
Billy's Little Trip wrote:fluffy wrote:Hey! Where ya been?
(Also I am pretty sure your name is not Guido.)
That's because you don't have ESPN (extrasensory perception knowledge...the K is silent)
Business finally started getting better. I couldn't sell a gold fish pond towards the end of 08, and now I'm closing huge projects. YAY!!! Jon will be happy to know that he campaigned for the right guy, lol.
I need to rock again. I miss all you freaks, geeks and alcoholics.

You
do need to rock again.
(Ahh... the old dumbrella board had an emoticon of the Devil's Horns. I miss that.)
In fact, if you find yourself available again, then keep an eye on your PM box in the near future.
Re: 8-12-09 a snake in the pants
Posted: Sat Aug 15, 2009 9:01 am
by fluffy
Yeah this phpBB doesn't have

or

at all and it's sad
oh wait
Re: 8-12-09 a snake in the pants
Posted: Sat Aug 15, 2009 9:10 am
by Spud
It's also too bad you can't just link one from somewhere else

Re: 8-12-09 a snake in the pants
Posted: Sat Aug 15, 2009 9:33 am
by JonPorobil
I meant
the hand signal. You guys don't remember that?
Re: 8-12-09 a snake in the pants
Posted: Sat Aug 15, 2009 11:25 am
by Billy's Little Trip
Here's one with some head bangin'
This one looks like that strong bad guy.
