How do *you* use Python in non-GUI work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stef Mientki

    #16
    Re: How do *you* use Python in non-GUI work?

    John Salerno wrote:
    Hey all. Just thought I'd ask a general question for my own interest. Every time I think of something I might do in Python, it usually involves creating a GUI interface, so I was wondering what kind of work you all do with Python that does *not* involve any GUI work. This could be any little scripts you write for your own benefit, or what you do at work, if you feel like talking about that! :)
    >
    Thanks.
    --

    >
    If I look at the answers and
    if I skip the web designs, which in my opinion are almost pure GUI ;-) ,
    it would be interesting to know,
    which of the mentioned applications of non-GUI programs
    are used by others than the programmer him/herself.

    cheers,
    Stef

    Comment

    • Michael Torrie

      #17
      Re: How do *you* use Python in non-GUI work?

      sturlamolden wrote:
      Back in the 'old days' of Unix, programs tended not to be small, could
      only do one thing, and did it well. They had no gui, and all
      interaction came from command line options. The programs were invoked
      from the command line, and input and output were piped from one
      program to another (input on stdin, output on stdout).
      And of course Python is perfect in this area. A great example is found
      here:
      <snip>
      To answer your question: I only add GUIs when I have to. But because
      it seems that people are becoming computer illiterate, incapable of
      using a keyboard, and only comfortable with a certain point-and-click
      input device, it tends to be most of the time now.
      Python is excellent for gluing together components with a GUI. This
      preserves the modularity, diversity, functionality, and the ability to
      strings things together, but allows a nice easy way to interact with it.
      A great example is a GUI to drive ffmpeg or any number of transcoding
      pipelines. Command line switches are powerful but confusion, and well
      beyond my memory. Yet I prefer transcoders to work this way because I
      can string them together in different ways. Using wxPython or GTK or
      PyQT is ideal for bringing these tools together in a useful way. The
      perfect example of how a GUI should function.

      Comment

      • Michael Torrie

        #18
        Re: How do *you* use Python in non-GUI work?

        Michael Torrie wrote:
        And of course Python is perfect in this area. A great example is found
        here:
        ahem, http://www.dabeaz.com/generators/Generators.pdf

        Comment

        • John Salerno

          #19
          Re: How do *you* use Python in non-GUI work?

          On Sun, 18 May 2008 23:08:11 -0700 (PDT)
          s0suk3@gmail.co m wrote:
          Every now and then, however, I do build some interface (mostly GUI),
          such as a monitor, notification mechanism, etc. But I never feel like
          I'm losing focus on the actual problem; maybe because I develop the
          core program first and the think about a possible and optional
          interface. Maybe a good suggestion is to put the GUI stuff on another
          module or package, and make interface functions or methods to handle
          the needed GUI controls, so that the GUI stuff shows up as little as
          possible in the core part of the program.
          I certainly don't *not* like GUI programming. In fact, learning wxPython was really fun and interesting and I enjoy GUI stuff. And after learning about XRC (putting the GUI component in a separate XML file, away from the program logic) that helped me learn how to keep things separate as well. I even wrote a tutorial on how to use XRC with wxPython! :)

          Comment

          • David C. Ullrich

            #20
            Re: How do *you* use Python in non-GUI work?

            On Sun, 18 May 2008 18:20:22 -0400, John Salerno
            <johnjsal@NOSPA Mgmail.comwrote :
            >Hey all. Just thought I'd ask a general question for my own interest. Every time I think of something I might do in Python, it usually involves creating a GUI interface, so I was wondering what kind of work you all do with Python that does *not* involve any GUI work. This could be any little scripts you write for your own benefit, or what you do at work, if you feel like talking about that! :)
            You might get a keyboard with an Enter key, btw. Anyway:

            I'm a math professor, not a programmer.
            I use Python probably every day to do
            all sorts of things, for example:

            (i) Calculating grades. (Ok, this could be done in
            Excel. But if you know Python anyway you don't need
            to figure out how to do various things in Excel.
            Quick: In Excel how do you take all the quiz
            scores, drop the lowest _two_ of them and average
            the rest? Stumps people sometimes - if you're
            doing it by hand in Python it's no problem, you
            just do it.)

            (ii) Every semester I get a lot of emails asking
            about grades. Used to be tedious typing the same
            replies over and over, looking up the relevant
            numbers. A littls Python script takes the student's
            name, looks up the numbers and generates a reply
            automatically, including a summary of the scores
            and an explanation of how the grade was calculated.)

            (iii) Taking various data from various places and making
            it into HTML to post on the department web site.
            (Please don't look - a lot of that stuff is currently
            broken due to improvements on the server introduced
            by other faculty. These things happen when nobody's
            in charge so things get done by whoever's willing
            to do them...)

            (iv) Say I want to display the following system
            of equations on a quiz:

            3x + 2y + z = 3
            x - z = 1.

            Writing TeX to get the variables to line
            up properly can be tedious. A little Python
            thingie takes lists of variable names and
            coefficients and automatically produces
            TeX that displays the equations exactly right.

            I could go on and on - I use computers for a lot
            of things, and any time I want to do something
            but it's not obvious how to do it in the relevant
            big program Python gets pulled out to do the job.

            A meta-example: I'm about to publish a book on
            [never mind, the topic is still secret.] Python
            has been incredibly useful in writing that book,
            in many different ways. For example:

            (v) Making modifications to the text itself. For
            example, the other day I finally figured out how
            to make a certain aspect of the thing look right.
            So I wanted to replace every "$$[w]\qed" in the
            text (where [w] denotes any amount of white space)
            with "\QED$$". Took about a minute to make a Python
            script to go through the entire book and make the
            change.

            (vi) There are a lot of figures. Some fairly
            complicated, illustrating fairly complicated
            mathematical things. The figures are eps files
            that were generated by Python scripts. The simple
            ones could just have easily been done in Adobe
            Illustrator or Corel Whatever, but there's no
            way you're going to use a mouse-based program
            like that to draw the complicated figures and
            have everything in exactly the right place.
            I have Python do the calculations and then
            write the corresponding eps file, done.

            (vii) Many magical things were done with a
            combination of TeX macros and Python scripts.
            For example, index entries: If I say
            \index{Some Theorem} in the text and it turns
            out that that's on page 37 then
            "Some Theorem p.37" appears in the index;
            now if something gets revised so the
            \index{Some Theorem} is now on page 38 then
            the index entry is automatically revised to
            page 38.

            Or: The first page of Chapter n+1 is supposed
            to be the smallest odd number larger than the
            last page of Chapter n. A Python script typesets
            ("texs") each chapter; after typesetting Chapter
            n it looks and sees what the last page is,
            figures out what the first page of Chapter n+1
            should be, and modifies the code for Chapter n+1
            to start on the page before typesetting it.

            If I wrote this tomorrow the list of examples
            would be different. Just now over on
            comp.text.tex I showed someone a Python solution
            to a problem he had. I don't know if he's going
            to use it - he _would_ need to learn a _little_
            Python first. But it's what I'd use if _I_ wanted
            to solve the problem! Other people suggested various
            programs available that would solve his problem
            for him - writing a little Python to give the
            solution took less time than downloading one
            of those programs would have.
            >Thanks.
            David C. Ullrich

            Comment

            Working...