Need feedback on subprocess-using function

2009-10-03 Thread gb345
I'm relatively new to Python, and I'm trying to get the hang of using Python's subprocess module. As an exercise, I wrote the Tac class below, which can prints output to a file "in reverse order", by piping it through the Unix tac utility. (The idea is to delegate the problem of managing the m

Re: Need feedback on subprocess-using function

2009-10-09 Thread gb345
In Nobody writes: >You could always lift the code from Popen._communicate(), which uses >threads for Windows and select() for POSIX. Thanks. A lot of useful advice in your replies. G. -- http://mail.python.org/mailman/listinfo/python-list

Re: rfc: a self-editing script

2009-10-10 Thread gb345
In <0059c2b1$0$26930$c3e8...@news.astraweb.com> Steven D'Aprano writes: >But if you absolutely have to write to the program file... No, don't have to, beyond the urge to satisfy a very idiosyncratic aesthetic imperative... >then append your >data to the end of the file (as a comment) and late

rfc: a self-editing script

2009-10-12 Thread gb345
The following fragment is from a tiny maintenance script that, among other things, edits itself, by rewriting the line that ends with '### REPLACE'. ## import re import fileinput LAST_VERSION = 'VERSION 155' ### REPLACE ser

Re: Most efficient way to "pre-grow" a list?

2009-11-08 Thread gb345
In Luis Alberto Zarrabeitia Gomez writes: >¿Have you ever tried to read list/matrix that you know it is not sparse, but >you jdon't know the size, and it may not be in order? A "grow-able" array would just >be the right thing to use - currently I have to settle with either hacking >together my

Need help w 'Broken pipe' handling

2010-02-03 Thread gb345
Hi! I'm having a hard time figuring out how to handle a Unix SIGPIPE exception cleanly. The following short script illustrates the problem: -- #!/usr/bin/python # sigpipebug.py import sys import random from signal import signal,

Need advice on starting a Python group

2010-03-11 Thread gb345
I'm hoping to get advice from anyone with prior experience setting up a Python group. A friend of mine and I have been trying to start a scientific-programming-oriented Python group in our school (of medecine and bio research), with not much success. The main problem is attendance. Even thou

UnicodeEncodeError during repr()

2010-04-18 Thread gb345
I'm getting a UnicodeEncodeError during a call to repr: Traceback (most recent call last): File "bug.py", line 142, in element = parser.parse(INPUT) File "bug.py", line 136, in parse ps = Parser.Parse(open(filename,'r').read(), 1) File "bug.py", line 97, in end_item r = rep

Re: UnicodeEncodeError during repr()

2010-04-19 Thread gb345
In "Martin v. Loewis" writes: >> Do I need to do something especial to get repr to work strictly >> with unicode? >Yes, you need to switch to Python 3 :-) >> Or should __repr__ *always* return bytes rather than unicode? >In Python 2.x: yes. >> What about __str__ ? >Likewise. >> If both of

Re: Looking for registration package

2010-04-30 Thread gb345
In a...@pythoncraft.com (Aahz) writes: >In article , kj wrote: >> >>I'm looking for a Python-based, small, self-contained package to >>hand out API keys, in the same spirit as Google API keys. >> >>The basic specs are simple: 1) enforce the "one key per customer" rule; >>2) be robot-proof; 3) b

Need feedback on ORF-extracting code

2009-08-12 Thread gb345
Hi everyone. I'm relatively new to Python, and could use your feedback on the code below. First some nomenclature. A "nucleotide" is one of A, C, G, T, or U. (In practice, a sequence of such nucleotides never contains both T and U, but this fact is not important in what follows.) A "codon" i

Modules/packages by GvR?

2009-08-28 Thread gb345
Are there any Python-only modules or packages in the latest releases of Python 2.x or Python 3.x that were largely written by Guido van Rossum? What's the best way to find this out? I know that some modules mention the author(s) in the source code, but this does not seem to be true most of th

Module for Fisher's exact test?

2009-09-06 Thread gb345
Before I roll my own, is there a good Python module for computing the Fisher's exact test stastics on 2 x 2 contingency tables? Many thanks in advance, Gabe -- http://mail.python.org/mailman/listinfo/python-list

Unix-head needs to Windows-ize his Python script

2010-10-20 Thread gb345
I have a handy Python script, which takes a few command-line arguments, and accepts a few options. I developed it on Unix, with very much of a Unix-mindset. Some Windows-using colleagues have asked me to make the script "easy to use under Windows 7". I.e.: no command-line. Therefore, I want

Unix-head needs to Windows-ize his Python script (II)

2010-10-22 Thread gb345
In gb345 writes: >I have a handy Python script, which takes a few command-line >arguments, and accepts a few options. I developed it on Unix, with >very much of a Unix-mindset. Some Windows-using colleagues have >asked me to make the script "easy to use under Windows 7&quo

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-22 Thread gb345
In Tim Golden writes: >On 22/10/2010 15:25, gb345 wrote: >> 3. Both versions of the app work fine on Windows 7, as long as >> I do the following: >>a. run CMD >>b. cd to where the GUI script and my original script live >>c. execute eith

How to get dynamically-created fxn's source?

2010-11-05 Thread gb345
For a project I'm working on I need a way to retrieve the source code of dynamically generated Python functions. (These functions are implemented dynamically in order to simulate "partial application" in Python.[1]) The ultimate goal is to preserve a textual record of transformations performed

Re: How to get dynamically-created fxn's source?

2010-11-08 Thread gb345
In Peter Otten <__pete...@web.de> writes: >gb345 wrote: >> For a project I'm working on I need a way to retrieve the source >> code of dynamically generated Python functions. (These functions >> are implemented dynamically in order to simulate "partial app