[Pythonmac-SIG] pythonw and python with applescript

Zhi Peng zhiyong_peng2003 at yahoo.com
Tue Dec 13 22:30:12 CET 2005


Bob
   
  Actually there is only one step away, that is, pythonw and python. With python, I can import modules by using PyImport_ImportModule("name"). But I have to use pythonw since I used appscript. Then I can not import modules sucessfully with same commands.
   
  If converting C code to python, there will be a lot of changes too because C is strict typed language while python everything is Object. I have to make .so or .dylib in order to allow python code to call C code. That will be still a lot of work.  
   
  Regards 
   
  Zhi 

Bob Ippolito <bob at redivi.com> wrote:
  You don't have to change it all to Python, you just need to refactor it a bit.? Instead of embeding Python from C, you embed C from Python.? Of course, it's better to prefer Python code because there will be less of it, it's not always a good idea to just throw all the old code away.  

  -bob
  
    On Dec 13, 2005, at 12:46 PM, Zhi Peng wrote:

    Hi! Bob 
  ?
  What you suggested is right. 
  ?
  The interesting thing is that I have a lot of old c code which will try to call python code. It is true that I can write pure python code and use py2app (I use py2exe on windows) to make an executable. That? will make life easy. But .. 
  ?
  I think that I need to do something as you said, try to change all C code to python, it may be easier than that I embeded python to C. 
  ?
  Thanks all .
  ?
  Zhi 
  ?
  

Bob Ippolito <bob at redivi.com> wrote:
  
On Dec 13, 2005, at 12:18 PM, Zhi Peng wrote:

> If we use pythonw, then there may be problem in C code to call the 
> python code with appscript inside because it seems > PyImport_ImportModule("ModuleName") only works with python instead 
> of pythonw.

pythonw is just a shell script. You're embedding Python, it's not 
even an option. You must use an application bundle in order to 
communicate with WindowServer.

You probably shouldn't be embedding Python in the first place.. Much 
easier that way, because py2app can create the application bundle for 
you, and you don't have to deal with all of the initialization/ 
finalization for Python.

-bob


  

  

  
---------------------------------
  Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping  _______________________________________________
  Pythonmac-SIG maillist? -? Pythonmac-SIG at python.org
  http://mail.python.org/mailman/listinfo/pythonmac-sig



  


			
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051213/6c54ae8e/attachment-0001.htm


More information about the Pythonmac-SIG mailing list