On Sun, 18 May 2008 18:20:22 -0400, John Salerno <[EMAIL PROTECTED]> 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! :) 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 -- http://mail.python.org/mailman/listinfo/python-list