Re: Faster way to do this...

2005-03-01 Thread Warren Postma
Will McGugan wrote:
Isn't that equivalent to simply..
nums= range(100)
I remember the day I first realized that 900 lines of some C++ program I 
was working on could be expressed in three lines of python.  Ahh.
Rebirth.  Then there was the phase of the python-newbie so enamored of 
map and lambda.  ... Wait, actually, I'm not out of that yet. :-)

Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 removes None data type?

2005-03-04 Thread Warren Postma
[EMAIL PROTECTED] wrote:
I just read in the 'What's New in Python 2.4' document that the None
data type was converted to a constant:
http://python.org/doc/2.4/whatsnew/node15.html
Implication: A long standing wart in Python now gone.  Its time to 
gloat. Are there any really evil glitches LEFT in Python? Now go look at 
  Perl and come back and say "Thank-deity-of-my-choice-I'm-using-Python".

Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: shuffle the lines of a large file

2005-03-07 Thread Warren Postma
Joerg Schuster wrote:
Unfortunately, none of the machines that I may use has 80G RAM.
So, using a dictionary will not help.
Any ideas?
Why don't you index the file?  I would store the byte-offsets of the 
beginning of each line into an index file. Then you can generate a 
random number from 1 to Whatever, go get that index from the index file,
then open your text file, seek to that position in the file, read one 
line, and close the file. Using this process you can then extract a 
somewhat random set of lines from your 'corpus' text file.

You probably should consider making a database of the file, keep the raw 
text file for sure, but create a converted copy in bsddb or pytables format.

Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: intigrate the PyGame module with my Python

2005-03-07 Thread Warren Postma

1. Downloaded the windows binary for python 1.5.2 from python.org.
Pygame uses Python 1.5.2 still!? :-) Oi.
Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 removes None data type?

2005-03-07 Thread Warren Postma
Michael Hoffman wrote:
The fact that True and False are not constants?
Yowza.
a = True
b = False
False = a
True = b
if (1==2)==True:
print "Doom"
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.4 removes None data type?

2005-03-07 Thread Warren Postma
Michael Hoffman wrote:
The fact that True and False are not constants?
Yowza.
a = True
b = False
False = a
True = b
if (1==2)==True:
print "Doom"
--
http://mail.python.org/mailman/listinfo/python-list


Re: boring the reader to death (wasRe: Lambda: the Ultimate DesignFlaw

2005-04-05 Thread Warren Postma
Donn Cave wrote:
That's an odd thing to say.  Poetry is verbose, florid?
Python is Dutch.
Ha. I'm vaguely dutch, whatever that means.
I would say if there is a sister word for "Programming" in the english 
language, it isn't Poetry and it surely isn't Prose. It's Dialectic.
I appreciate the idea of "Code Poetry", and I find more than a few 
coders out there with more than a rudimentary appreciation of Poetry as 
well, but I don't like the analogy. No slight to Poetry is intended. 
Rather, I intend it as a compliment. Code has an almost entirely 
practical purpose, Malbol et al excluded. Poetry, except in cases of 
extraordinarily bad poetry, may have little "practical" purpose.

Now dialectic. I like that word. And I think the art of programming is 
somewhere in the Late-Medeival period right now. From Merriam Webster, 
meanings 1,5,6 seem rather sympathetic to texts used in the creation of 
software:

Dialectic
1. LOGIC
5.  Any systematic reasoning, exposition, or argument that juxtaposes 
opposed or contradictory ideas and usually seeks to resolve their 
conflict/an intellectual exchange of ideas
6 : the dialectical tension or opposition between two interacting forces 
or elements

One way to look at Code is as a textual abstraction of a design. Having 
been flattened from brain-space into a two dimension matrix of latin 
glyphs, certain semantic/meta-data is typically omitted. Thus a 
classical programming problem in many languages: The "Write-only-code" 
syndrom. You wrote it, it runs, but you're afraid even to touch it 
yourself.  Python is stronger than other languages I have used.  When I 
go back to Python code I've written long enough ago to have forgotten 
everything about, I am more able to pick it up and work with it than I 
am with other less agile languages. I'm not merely talking about 
pedantic details of literal code-readability, I'm talking about the 
ability to intuit design from implementation, and the orthogonality of 
the design of the system to the to the faculty of human reason. (In not 
so many words: Python fits my brain.)

Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: Testing threading

2005-04-07 Thread Warren Postma
George Sakkis wrote:
How one goes on testing a threaded program, apart from doing a few
successful runs and crossing his fingers that it at least follows the
'correct 99.% of the time' rule ? 
If you haven't been in there and stepped through all the code, looked 
for a reasonable set of test cases, and tried those test cases, then you 
haven't tested! :-)

You test a threaded program the same way you test a non-threaded
program. Thoroughly.  Test cases. YOu don't *have* to write unit tests,
but it sure helps. Code running a few times isn't tested.  If you
prefer to test manually, really want to be thorough you have to find 
ways to make sure you've done coverage of a reasonable set of test 
cases.  How do I get myself a set of test cases? Personally I like to 
walk through my code in a debugger and ask myself "how could this go 
wrong?".  "What if I pass a huge amount of data in here? How 
unresponsive can I find ways to make this thread get?" "If this is a 
network communications thread, let's try all the various error 
conditions that can happen on a real network.". ...

When I think of an idea on how things could go wrong ("What happens if
the data isn't here or is invalid?"/"Where should I be catching 
exceptions and how should I be handling them?")

Regards,
Warren
--
http://mail.python.org/mailman/listinfo/python-list


Re: cross platform printing

2005-04-07 Thread Warren Postma
David Isaac wrote:
OK, I'll assume silence means "no", so new question:
What is the current best practice for cross platform printing of PostScript
files from Python?
Well since printing postscript files on most Unix systems (probably 
including Mac OSX although I don't really know this for sure) is 
trivially easy, why not investigate using cygwin  on Windows and 
launching an "lpr" task from your python script that prints the given 
postscript file. Implementation time on Unix: 0 minutes, 0 seconds. 
Implementation time on Windows; the time it takes make a cygwin batch 
file that prints using ghostscript.

Regards,
Warren
--
http://mail.python.org/mailman/listinfo/python-list


Whither python24.dll? {WinCvs 2.0 and Python}

2005-04-12 Thread Warren Postma
It seems that WinCvs needs a python??.dll runtime but that when I 
install Python2.4 it doesn't include this dll.

Python 2.3 does.
What's the recommendation here?
Warren
--
http://mail.python.org/mailman/listinfo/python-list