How does python call OS?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Siegfried Heintze

    How does python call OS?

    I just finished reading a chapter in "Python Programming on Win32" and tried
    out the pythonwin scribble application. I'm not sure if I got it right
    because I could not open a new document. I tried to download the source code
    as referenced in the chm file but it is corrupted. I cut and pasted from my
    softcopy of the book.

    I see the next sub-chapter on wxWindows for python and the previous
    sub-chapter on TK. This is looking a lot like other scripting languages
    (such as perl and groovy and even java). Can python call anything directly
    or does someone have to write a DLL in C/C++ that calls the function first?
    Thanks!
    Siegfried


  • Steven D'Aprano

    #2
    Re: How does python call OS?

    On Sat, 13 Sep 2008 23:51:39 -0700, Siegfried Heintze wrote:
    I see the next sub-chapter on wxWindows for python and the previous
    sub-chapter on TK. This is looking a lot like other scripting languages
    (such as perl and groovy and even java). Can python call anything
    directly or does someone have to write a DLL in C/C++ that calls the
    function first? Thanks!

    I'm not sure I understand your question correctly, but Python can call
    external programs in a number of ways. I believe the "best" way to do so
    is with the subprocess module.



    --
    Steven

    Comment

    • Gary Herron

      #3
      Re: How does python call OS?

      Siegfried Heintze wrote:
      I just finished reading a chapter in "Python Programming on Win32" and tried
      out the pythonwin scribble application. I'm not sure if I got it right
      because I could not open a new document. I tried to download the source code
      as referenced in the chm file but it is corrupted. I cut and pasted from my
      softcopy of the book.
      >
      I see the next sub-chapter on wxWindows for python and the previous
      sub-chapter on TK. This is looking a lot like other scripting languages
      (such as perl and groovy and even java). Can python call anything directly
      or does someone have to write a DLL in C/C++ that calls the function first?
      Thanks!
      Siegfried
      See the ctypes module for a method of calling any C callable function in
      and DLL.

      Gary Herron

      Comment

      • Grant Edwards

        #4
        Re: How does python call OS?

        On 2008-09-14, Siegfried Heintze <siegfried@hein tze.comwrote:
        I just finished reading a chapter in "Python Programming on Win32" and tried
        out the pythonwin scribble application. I'm not sure if I got it right
        because I could not open a new document. I tried to download the source code
        as referenced in the chm file but it is corrupted. I cut and pasted from my
        softcopy of the book.
        >
        I see the next sub-chapter on wxWindows for python and the
        previous sub-chapter on TK. This is looking a lot like other
        scripting languages (such as perl and groovy and even java).
        Can python call anything directly
        No. For example, I don't believe there's any way for standard
        C-Python to make system calls on Linux. [Thought ISTR that
        somebody has written an extension module that doess that.]
        or does someone have to write a DLL in C/C++ that calls the
        function first?
        Can you be more explicit? What sort of "function" are you
        talking about?

        As for calling functions in libraries, the library doesn't have
        to be in C/C++. Python can make library calls written in any
        language (Fortran, Ada, Pascal, etc.) as long as the language
        uses a supportted API. Python can also execute external
        programs.

        --
        Grant

        Comment

        Working...