<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Can anyone tell me how to call and exectute C code in Python?</span></div><div><br><span></span></div><div><span>Regards.</span></div><div><br><span></span></div><div><span>David<br></span></div><div><br></div>  <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> "python-list-request@python.org" <python-list-request@python.org><br> <b><span style="font-weight: bold;">To:</span></b> python-list@python.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Friday, 11 May 2012, 5:35<br> <b><span style="font-weight: bold;">Subject:</span></b> Python-list Digest, Vol 104, Issue 57<br>
 </font> </div> <br>----- Forwarded Message -----<br><br>Send Python-list mailing list submissions to<br>    <a ymailto="mailto:python-list@python.org" href="mailto:python-list@python.org">python-list@python.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>or, via email, send a message with subject or body 'help' to<br>    <a ymailto="mailto:python-list-request@python.org" href="mailto:python-list-request@python.org">python-list-request@python.org</a><br><br>You can reach the person managing the list at<br>    <a ymailto="mailto:python-list-owner@python.org" href="mailto:python-list-owner@python.org">python-list-owner@python.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of
 Python-list digest..."<br><br>Today's Topics:<br><br>   1. Looking for video/slides from PyCon 2011... (Monte Milanuk)<br>   2. Re: Dealing with the __str__ method in classes with lots of<br>      attributes (Cameron Simpson)<br>   3. RE: Open Source: you're doing it wrong - the Pyjamas hijack<br>      (Adrian Hunt)<br>   4. RE: Creating a Windows installer for Python + a set of<br>      dependencies (Adrian Hunt)<br>   5. Re: Open Source: you're doing it wrong - the Pyjamas hijack<br>      (Chris Angelico)<br>   6. Re: Retrieving result from embedded execution (Chris Angelico)<br>   7. Finding the line number of an 'else' statement via ast<br>      (Michael Rene Armida)<br>...specifically the two lectures on creating GUI applications with Python + QT<br><br><a href="http://us.pycon.org/2011/schedule/presentations/207/"
 target="_blank">http://us.pycon.org/2011/schedule/presentations/207/</a><br><br>Various searches on the 'Net don't seem to be turning up much... kinda curious as to why?<br><br>Anyone here know?<br><br>TIA,<br><br>Monte<br><br><br>On 10May2012 15:33, Andreas Tawn <<a ymailto="mailto:andreas.tawn@ubisoft.com" href="mailto:andreas.tawn@ubisoft.com">andreas.tawn@ubisoft.com</a>> wrote:<br>| Say I've got a class...<br>| <br>| class test(object):<br>|     def __init__(self):<br>|         self.foo = 1<br>|         self.bar = 2<br>|         self.baz = 3<br>| <br>| I can say...<br>| <br>| def __str__(self):<br>|    return "foo: {0}\nbar: {1}\nbaz: {2}".format(self.foo, self.bar, self.baz)<br>| <br>| and everything's simple and clean and I can vary the formatting if I need to.<br>| <br>| This gets ugly when the class has a lot of attributes because the string construction gets
 very long.<br><br>This issue bit me once too often a few months ago, and now I have a<br>class called "O" from which I often subclass instead of from "object".<br>Its main purpose is a friendly __str__ method, though it also has a<br>friendly __init__.<br><br>Code:<br><br>    class O(object):<br>      ''' A bare object subclass to allow storing arbitrary attributes.<br>          It also has a nicer default str() action, and an aggressive repr().<br>      '''<br><br>      def __init__(self, **kw):<br>        ''' Initialise this O.<br>            Fill in attributes from any keyword arguments if supplied.<br>            This call can be omitted in subclasses if desired.<br>        '''<br>        for k in kw:<br>          setattr(self,
 k, kw[k])<br><br>      def __str__(self):<br>        return ( "<%s %s>"<br>                 % ( self.__class__.__name__,<br>                     ",".join([ "%s=%s" % (attr, getattr(self, attr))<br>                                for attr in sorted(dir(self)) if attr[0].isalpha()<br>                              ])<br>                   )<br>               )<br><br>So I have some code thus:<br><br>  from cs.misc import O<br>  ......<br>  class FilterModes(O):<br>    def __init__(self, **kw):<br>        # special case one parameter<br>   
     self._maildb_path = kw.pop('maildb_path')<br>        self._maildb_lock = allocate_lock()<br>        O.__init__(self, **kw)<br>  ......<br>  filter_modes = FilterModes(justone=justone,<br>                             delay=delay,<br>                             no_remove=no_remove,<br>                             no_save=no_save,<br>                             maildb_path=os.environ['MAILDB'],<br>                             maildir_cache={})<br><br><br>This removes a lot of guff from some common procedures.<br><br>Hope this helps,<br>--
 <br>Cameron Simpson <<a ymailto="mailto:cs@zip.com.au" href="mailto:cs@zip.com.au">cs@zip.com.au</a>> DoD#743<br><a href="http://www.cskk.ezoshosting.com/cs/" target="_blank">http://www.cskk.ezoshosting.com/cs/</a><br><br>There's a fine line between pathos and pathetic.<br>        - David Stivers <a ymailto="mailto:stiv@stat.rice.edu" href="mailto:stiv@stat.rice.edu">stiv@stat.rice.edu</a> DoD #857<br><br><div id="yiv34787414">

<style><!--
#yiv34787414 .yiv34787414hmmessage P
{
margin:0px;padding:0px;}
#yiv34787414 body.yiv34787414hmmessage
{
font-size:10pt;font-family:Tahoma;}
--></style>
<div><div dir="ltr">
lol, Cheers Chris.<br><br>Just so you know, I care about what and how I write... I almost always run my emails though a word-processor before sending. And, that has paid off for me: thanks to MS Word, MS Works and Open Office, I have better understanding of "correct" punctuation use (if not spelling and grammar) than most school leavers!!!<br><br>PS. It hasn't gone a miss that you are one of the core python-list responders (and I bet this goes for most of the python-list users): your responses, time and knowledge is appreciated... Thank you.<br><br><div><div id="yiv34787414SkyDrivePlaceholder"></div>> Date: Fri, 11 May 2012 09:57:49 +1000<br>> Subject: Re: Open Source: you're doing it wrong - the Pyjamas hijack<br>> From: rosuav@gmail.com<br>> To: python-list@python.org<br>> <br>> On Fri, May 11, 2012 at 9:36 AM, Adrian Hunt <cyborgv2@hotmail.com> wrote:<br>> > All I did was to answer a mail sent to me by Ian Kelly (who I
 don't konw nor<br>> > have ever had any prior contact with) about releasing code under a<br>> > license... And, what I said stands: once anyone releases code, they are<br>> > bound by the license they released it under as much as anyone else that may<br>> > use it and cannot then withdraw that code from the domain they released it<br>> > to (except by maybe creating a new and different version.)<br>> <br>> And that's absolutely correct. Open source licenses are deliberately<br>> worded to guarantee rights in perpetuity, so there's no way to<br>> withdraw it or change the license (though of course a copyright owner<br>> can release the same code under an additional license).<br>> <br>> > Being dyslexic, my message (and this one) may not be worded in the best way<br>> > but that is no reason to start on me!<br>> <br>> Your message is fine. Believe you me, I'd much rather read a
 message<br>> posted by a non-native English speaker, or a dyslexic person, or<br>> someone who has a clinical aversion to the letter 'q', than someone<br>> who's simply sloppy and doesn't care about their language at all.<br>> <br>> Chris Angelico<br>> -- <br>> http://mail.python.org/mailman/listinfo/python-list<br></div>                                           </div></div>
</div><div id="yiv1448135580">

<style><!--
#yiv1448135580 .yiv1448135580hmmessage P
{
margin:0px;padding:0px;}
#yiv1448135580 body.yiv1448135580hmmessage
{
font-size:10pt;font-family:Tahoma;}
--></style>
<div><div dir="ltr">
Hi there,<br><br>I've use NSIS for quite a few projects... NSIS will do it with ease. You write a script that gets "compiled" into a install exe and the scripting language is not too hard to learn. You can do it in several different ways:<br><br>1. You can include the Python installer as a file compressed into your installer (that is decompressed to a temp directory before being run.)<br>2. The Python installer could be a included along side you installer and run as needed<br>3. You can specify a URL to the Python install to be downloaded and installed (again using a temp directory.)<br><br>You can even use a mix... If an internet connection is available download it, if not fall back to one of the other methods. If you can come up with yet another method, it wouldn't be simple to write a script to handle it.  If you really need to you can write a dynamic link library that the final NSIS installer will make calls to.<br><br>If you need any more help
 on this subject, email me directly... Although I try to keep an eye on python-list, I can't guarantee a quick reply.<br><br><br><br><div><div id="yiv1448135580SkyDrivePlaceholder"></div>> Date: Thu, 10 May 2012 16:26:25 +0200<br>> Subject: Creating a Windows installer for Python + a set of dependencies<br>> From: g.rodola@gmail.com<br>> To: python-list@python.org<br>> <br>> Hi all,<br>> I need to create an installer for Windows which should be able to<br>> install a specific version of the Python interpreter (2.7) plus a set<br>> a dependencies such as ipython, numpy, pandas, etc.<br>> Basically this is the same thing Active State did for their Active<br>> Python distribution: a single bundle including interpreter + deps.<br>> Not being a Windows user I'm not sure where to start with this except<br>> maybe looking into NSIS (could that be of any help?).<br>> <br>> Thanks in advance,<br>> <br>> ---
 Giampaolo<br>> http://code.google.com/p/pyftpdlib/<br>> http://code.google.com/p/psutil/<br>> http://code.google.com/p/pysendfile/<br>> -- <br>> http://mail.python.org/mailman/listinfo/python-list<br></div>                                          </div></div>
</div>On Fri, May 11, 2012 at 10:21 AM, Adrian Hunt <<a ymailto="mailto:cyborgv2@hotmail.com" href="mailto:cyborgv2@hotmail.com">cyborgv2@hotmail.com</a>> wrote:<br>> lol, Cheers Chris.<br>><br>> Just so you know, I care about what and how I write... I almost always run<br>> my emails though a word-processor before sending. And, that has paid off for<br>> me: thanks to MS Word, MS Works and Open Office, I have better understanding<br>> of "correct" punctuation use (if not spelling and grammar) than most school<br>> leavers!!!<br><br>Absolutely. Taking care puts you miles ahead of the average<br>(unfortunately for the average). I was home educated, and taught to<br>value correctness, so I tend to speak and write more carefully than<br>most do (people say I sound British for some reason - my accent<br>doesn't sound Australian). That's why I tend to do a lot (note, not<br>"alot", though the cute drawings are fun) of
 copyediting.<br><br>> PS. It hasn't gone a miss that you are one of the core python-list<br>> responders (and I bet this goes for most of the python-list users): your<br>> responses, time and knowledge is appreciated... Thank you.<br><br>Thanks! I'm just a guy who types fast, mainly; but I've been coding<br>for about twenty years, and I'm always happy to help people. But this<br>list is more for me to learn than for me to share. I've learned no end<br>of things from these threads - it's awesome!<br><br>ChrisA<br><br>On Wed, May 9, 2012 at 5:07 AM, F L <<a ymailto="mailto:mephisto_9000@hotmail.com" href="mailto:mephisto_9000@hotmail.com">mephisto_9000@hotmail.com</a>> wrote:<br>> Hello everyone,<br>><br>> We are trying to implement our own interactive interpreter in our<br>> application<br>> using an embedded Python interpreter.<br>><br>> I was wondering what would be the best way to retreive as text the result
 of<br>> executing Python code. The text must be exactly the same as it would be in<br>> the<br>> standalone interpreter.<br><br>Greetings!<br><br>The standalone interpreter - I assume you mean the interactive prompt?<br>It has slightly different handling of things (for instance, naked<br>expressions being written to standard output) from the more "usual"<br>invocation of the interpreter.<br><br>For your embedded Python, probably the easiest thing to do is to not<br>try to use interactive mode, but script mode:<br><br>PyObject* PyRun_String(const char *str, int start, PyObject *globals,<br>PyObject *locals)<br><br>Pass it a string of Python code and a dictionary to use for globals<br>and locals (they can be the same dict). Then when that finishes,<br>retrieve from that dictionary some predetermined name (eg "Output").<br>The Python code then needs simply to assign to Output and all will<br>work.<br><br>Another way to do it is to call a function
 inside the Python code, and<br>retrieve its return value.<br><br>> We are using python 2.7.<br>><br>> Any suggestions?<br><br>Unless you have particular need to stick to the 2.x branch, I would<br>suggest moving to 3.3; many things are easier (especially Unicode).<br>But both work.<br><br>> Also, I'm new to mailling lists, what is the proper way to reply to someone?<br>> Should I<br>> reply directly to someone's email adress or is there a way to answer trough<br>> the server.<br><br>The usual convention is to reply on-list, unless it's particularly<br>private. Many mail clients will handle this conveniently; otherwise,<br>just manually replace the To address with the list address. As long as<br>you use reply (rather than starting a fresh email), all posts will be<br>correctly threaded both on the list and on the synchronized newsgroup<br>(comp.lang.python).<br><br>Chris Angelico<br><br>Given this source:<br><br>def
 do_something(val):<br>    if val:<br>        return 'a'<br>    else:<br>        return 'b'<br><br>How do I get the line number of the "else:" line, using the ast<br>module?  The grammar only includes the 'orelse' list:<br><br>    If(expr test, stmt* body, stmt* orelse)<br><br>...but 'orelse' is the list of statements under the 'else' token, not<br>a node representing the token itself.<br><br>I have a suspicion that this isn't possible, and shouldn't be, and the<br>giveaway word above was "token."  Because the tokens themselves aren't<br>part of the abstract syntax tree.<br><br>Here's an interactive session showing me poking around the If node:<br><br>>>> import ast<br>>>> tree = ast.parse('''<br>... if True:<br>...     pass<br>... else:<br>...     pass<br>... ''')<br>>>> tree.body[0].orelse<br>[<_ast.Pass object at
 0x7f1301319390>]<br>>>> tree.body[0]._fields<br>('test', 'body', 'orelse')<br>>>> for i in ast.iter_child_nodes(tree.body[0]):<br>...     print i.__class__.__name__<br>...<br>Name<br>Pass<br>Pass<br><br><br>Is my suspicion correct?  Or is there a way to get the line number of<br>that 'else:'?<br><br><br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br><br> </div> </div>  </div></body></html>