Re: Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

2006-03-16 Thread Tim Roberts
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:

>[EMAIL PROTECTED] wrote:
>
>> The problem I'm trying to solve is.
>> There is a 5x5 grid.
>> You need to fit 5 queens on the board such that when placed there are
>> three spots left that are not threatened by the queen.
>
>when you're done with your homework (?), you can compare it with
>Guido's solution:
>
>http://svn.python.org/view/python/trunk/Demo/scripts/queens.py

That solves a different problem.  The traditional N queens problem would be
"place 5 queens so that none of them threatens another".  That's very
different from his problem specification.

It turns out there is only 1 unique (non-rotated, non-reflected) solution
to the problem as he posted it.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-16 Thread Tim Roberts
[EMAIL PROTECTED] wrote:
>
>Just tried Ruby over the past two days. I won't bore you
>with the reasons I didn't like it, however one thing really
>struck me about it that I think we (the Python community)
>can learn from.
>
>Ruby has ... an issue with docs. That is to say, there are
>almost none. ...
>
>IMO, Perl has docs nailed.

I know there are people who disagree with me, but I think the PHP community
has the right idea with their online docs.  The wiki-like community
participation adds a helpful extra dimension, giving practical tips and
pointing out non-obvious gotchas.

However, I'm sure it's a bear to administer.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Generator Paradox!

2006-03-16 Thread Fredrik Lundh
"vbgunz" wrote:

> I am afraid that this is the first time in which I would probably need
> something explained to me as if I were a little child. I am having a
> hard time getting this through my thick skull. What in the world is
> wrong with this!?
>
> ''' ### '''
>
> def generatorFunction(sequence=['item1', 'item2', 'item3']):
> for item in sequence:
> yield item
>
> yieldedValue = generatorFunction()
>
> '''this seems to work perfectly.'''
> print '-' * 32
> print yieldedValue  # 
> print yieldedValue.next()   # item1
> print yieldedValue.next()   # item2
> print yieldedValue.next()   # item3
>
> '''this is where things don't make any sense!'''
> print '-' * 32
> print generatorFunction()   # 
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
>
> ''' ### '''

does the following surprise you too ?

f = open("filename")
print f.readline() # prints first line
print f.readline() # prints second line
print f.readline() # prints third line

print open("filename").readline() # prints first line
print open("filename").readline() # prints first line
print open("filename").readline() # prints first line





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


Re: Is there a python library to parse C++ code file?

2006-03-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> Is there a python library to parse C++ code file?
> If yes, can you please tell me where is it?

depends on how you want to parse the file, and what information you
want to extract.  without more details, I'd recommend

http://www.gccxml.org/HTML/Index.html

combined with some python xml library, e.g.

http://www.effbot.org/zone/element-index.htm
http://www.effbot.org/zone/element-iterparse.htm

which gives you something like:

http://www.boost.org/libs/python/pyste/

which might be a good thing to look at before you start ...

or maybe you had something much simpler in mind ?





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


Re: Loop Backwards

2006-03-16 Thread Tim Roberts
"Dave" <[EMAIL PROTECTED]> wrote:
>
>Please be mindful of making statements such as:
>"it's silly to believe both will behave equally"
>
>One of the greatest weaknesses of Python is the less than friendly
>attitude Pythonistas display towards one another.

I don't know how much Usenet experience you've had, but comp.lang.python is
one of the friendliest places in the comp.lang universe.  Newbie questions
get answered without derision, and disagreements are handled with spirited
discussion, instead of flames and insults.  Compare, for example, to
comp.lang.c and comp.lang.c++.

>This example is why everyone is more excited about Ruby than Python.

That statement is just not true.  I've looked at Ruby, but syntactically it
will never sway me from Python.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Weekly Python Patch/Bug Summary

2006-03-16 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  392 open ( +6) /  3094 closed ( +5) /  3486 total (+11)
Bugs:  907 open (+18) /  5646 closed (+10) /  6553 total (+28)
RFE :  213 open ( +1) /   202 closed ( +1) /   415 total ( +2)

New / Reopened Patches
__

new exit and quit objects  (2006-03-09)
CLOSED http://python.org/sf/1446372  opened by  Georg Brandl

zipfile: support for ZIP64  (2006-03-09)
   http://python.org/sf/1446489  opened by  Ronald Oussoren

patch for 1441408  compiler fails to spot extended slice  (2006-03-09)
   http://python.org/sf/1446847  opened by  Grant Olson

Patch for bug 1441486: bad unary minus folding in compiler  (2006-03-09)
   http://python.org/sf/1446922  opened by  Grant Olson

logging: findCaller() sometimes raises AttributeError  (2006-03-10)
CLOSED http://python.org/sf/1447410  opened by  Kevin J Bluck

ConnectRegistry blocks all threads  (2006-03-12)
   http://python.org/sf/1448199  opened by  Lars L

decorator module  (2006-03-12)
   http://python.org/sf/1448297  opened by  Georg Brandl

declspec for ssize_t  (2006-03-12)
   http://python.org/sf/1448484  opened by  Zooko O'Whielacronx

const PyDict_Type ?  (2006-03-12)
   http://python.org/sf/1448488  opened by  Zooko O'Whielacronx

email.message.py charset can be unicode instance  (2006-03-13)
   http://python.org/sf/1449244  opened by  Tokio Kikuchi

Splitting CJK codecs from pythoncore dll  (2006-03-14)
   http://python.org/sf/1449471  opened by  Hye-Shik Chang

Patches Closed
__

new exit and quit objects  (2006-03-09)
   http://python.org/sf/1446372  closed by  gbrandl

logging: findCaller() sometimes raises AttributeError  (2006-03-10)
   http://python.org/sf/1447410  closed by  vsajip

Several minor fixes for NULL checks, etc.  (2006-03-06)
   http://python.org/sf/1444030  closed by  nnorwitz

New with semantics  (2006-03-08)
   http://python.org/sf/1445739  closed by  nnorwitz

Python memory allocator: Free memory  (2005-02-15)
   http://python.org/sf/1123430  closed by  tim_one

New / Reopened Bugs
___

extended slice behavior inconsistent with docs  (2006-03-09)
   http://python.org/sf/1446619  opened by  Steven Bethard

bug with xmlrpclib  (2006-03-09)
   http://python.org/sf/1446690  opened by  varun bhansaly

whatsnew 2.5: pep 353, python -m  (2006-03-09)
   http://python.org/sf/1447031  opened by  Gene Tani

tkinter Dialog fails when more than four buttons are used  (2006-03-10)
   http://python.org/sf/1447222  opened by  Hernan P. Dacharry

tkinter Dialog fails when more than four buttons are used  (2006-03-10)
CLOSED http://python.org/sf/1447234  opened by  Hernan P. Dacharry

Mac Framework build fails on intel  (2006-03-10)
   http://python.org/sf/1447587  opened by  Michael Mondragon

make frameworkinstall fails on Intel Macs  (2006-03-10)
   http://python.org/sf/1447607  opened by  Michael Mondragon

"reindent.py" exposes bug in tokenize  (2006-03-10)
CLOSED http://python.org/sf/1447633  opened by  Edward C. Jones

traceback.format_exception_only() and SyntaxError  (2006-03-11)
   http://python.org/sf/1447885  opened by  Remy Blank

Unable to stringify datetime with tzinfo  (2006-03-11)
   http://python.org/sf/1447945  opened by  Ilpo Nyyssönen

Defining a class with __dict__ brakes attributes assignment  (2006-03-11)
   http://python.org/sf/1448042  opened by  Michal Kwiatkowski

problems with too many sockets in FreeBSD  (2006-03-12)
   http://python.org/sf/1448058  opened by  aix-d

gettext.py breaks on plural-forms header  (2006-03-12)
   http://python.org/sf/1448060  opened by  Danilo Segan

re search infinite loop  (2006-03-12)
   http://python.org/sf/1448325  opened by  Don Allen

Convertion error for latin1 characters with iso-2022-jp-2  (2006-03-12)
CLOSED http://python.org/sf/1448490  opened by  Francois Duranleau

asyncore dispatcher.__getattr__() masks self._map  (2006-03-12)
   http://python.org/sf/1448639  opened by  Doug White

datetime.__init__ cannot be overridden  (2006-03-13)
CLOSED http://python.org/sf/1448640  opened by  Martin Blais

Subscript operations generating incorrect code  (2006-03-13)
CLOSED http://python.org/sf/1448804  opened by  Nick Coghlan

urllib2+https+proxy not working  (2006-03-13)
   http://python.org/sf/1448934  opened by  Rui Martins

urllib2+https+proxy not working  (2006-03-14)
CLOSED http://python.org/sf/1449397  opened by  Rui Martins

optparse: extending actions missing ALWAYS_TYPES_ACTIONS  (2006-03-13)
   http://python.org/sf/1449311  opened by  Christopher

Build of readline fails  (2006-03-14)
CLOSED http://python.org/sf/1450019  opened by  Sydney Weidman

int() and isdigit() accept non-digit numbers when using unic  (2006-03-15)
CLOSED http://python.org/sf/1450212  opened by  Pierre-Frédéric Caillaud

windows python truncates files when reading them  (2006-03-15)
CLOSED http:

Re: Threads modify "global" variable -- asking for trouble?

2006-03-16 Thread Terry Reedy

"J Rice" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> My apologizes, I missed the newish FAQ entry on this.  The addrbl()
> method looks like this:
>
> def addRBL(self, testname, result, info=""):
>self.testresultsRBL[testname] = result, info
>
> So according to the FAQ, D[x] = y, where D is a dictionary, is atomic
> and therefore thread-safe.  Right?

I believe an alternative, mentioned elsewhere by Tim Peters, is for workers 
to send results (here (testname,result,info) ) back in a results queue read 
by the main thread.

tjr



tjr



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


Re: Threads modify "global" variable -- asking for trouble?

2006-03-16 Thread Alex Martelli
J Rice <[EMAIL PROTECTED]> wrote:

> My apologizes, I missed the newish FAQ entry on this.  The addrbl()
> method looks like this:
> 
>  def addRBL(self, testname, result, info=""):
> self.testresultsRBL[testname] = result, info
> 
> So according to the FAQ, D[x] = y, where D is a dictionary, is atomic
> and therefore thread-safe.  Right?

In the current implementation specifically, for CPython exclusively, if
the hashing of testname is itself somehow 'atomic', and so is the access
to attribute testresultsRBL of object self, I do believe you might luck
out and end up "atomic" (by accident of implementation, only) if
everything's just right. Of course, any tiny change (any different
implementation of Python, any type that's not a pure primitive, any
future version of Python, etc, etc) could break this extremely fragile
set of circumstances -- Python as a language makes no guarantees of
atomicity for anything except the synchronization primitives (of which
Queue is the most powerful). There was a rather heated exchange on the
subject quite recently on this group.

Just put a lock acquire/release around this assignment (and any _use_ of
the same dictionary) and you should be vastly safer, IMNSHO.


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


Re: need some help in reading error message

2006-03-16 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote:

> I need some help in reading error message: which line has problem? line
> 233? or line 37?
> 
> Thank you.
> 
> $ ./read2.py log.xml
> Traceback (most recent call last):
>   File "./read2.py", line 233, in ?
> parser.parse(open(inputFileName))
>   File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
> line 109, in parse
> xmlreader.IncrementalParser.parse(self, source)
>   File "/usr/lib/python2.4/site-packages/_xmlplus/sax/xmlreader.py",
> line 123, in parse
> self.feed(buffer)
>   File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
> line 216, in feed
> self._parser.Parse(data, isFinal)
>   File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
> line 311, in start_element
> self._cont_handler.startElement(name, AttributesImpl(attrs))
>   File "./read2.py", line 37, in startElement
> openTable(self, "BlockGrouperExecuter input", self.type)
> AttributeError: LogHandler instance has no attribute 'type'

Line 37: specifically, self is an instance of LogHandler, and it does
not have any attribute named "type".


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


need some help in reading error message

2006-03-16 Thread Allerdyce . John
I need some help in reading error message: which line has problem? line
233? or line 37?

Thank you.

$ ./read2.py log.xml
Traceback (most recent call last):
  File "./read2.py", line 233, in ?
parser.parse(open(inputFileName))
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
line 109, in parse
xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/xmlreader.py",
line 123, in parse
self.feed(buffer)
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
line 216, in feed
self._parser.Parse(data, isFinal)
  File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py",
line 311, in start_element
self._cont_handler.startElement(name, AttributesImpl(attrs))
  File "./read2.py", line 37, in startElement
openTable(self, "BlockGrouperExecuter input", self.type)
AttributeError: LogHandler instance has no attribute 'type'

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


Re: Threads modify "global" variable -- asking for trouble?

2006-03-16 Thread J Rice

My apologizes, I missed the newish FAQ entry on this.  The addrbl()
method looks like this:

 def addRBL(self, testname, result, info=""):
self.testresultsRBL[testname] = result, info

So according to the FAQ, D[x] = y, where D is a dictionary, is atomic
and therefore thread-safe.  Right?

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


Threads modify "global" variable -- asking for trouble?

2006-03-16 Thread J Rice
I have been experimenting with some thread programming, but as I'm
doing this on my own I am worried I might be making a major mistake.

Here's a brief rundown of what I am working on.  Multiple threads, via
Queue, are used to perform RBL checks on an IP.  The threads are passed
a defined class (ConnectionScore) in their init.  This is used to
collect the results, including a method to add the result.  If I run
the program, everything goes fine and once all the threads complete the
main program has all the data from their RBL checks in the
ConnectionScore class.

It seems to work, even with an obscene (and silly) number of WORKERS
and RBLs to check.  But I was reading in the Python Cookbook this
evening and it raised the issue in my mind of what happens if multiple
threads try to add data to the class at the same time.

I've attached the code below.  The ConnectionClass.addRBL method just
takes the result and adds it to a dictionary object attached to the
class.


#!/usr/bin/python
from UCE_weight import ConnectionScore
from rbl import *
import Queue
import threading
import time, random

starttime = time.time()

WORKERS=5

class Worker(threading.Thread):

def __init__(self,queue,score):
self.__queue = queue
threading.Thread.__init__(self)
self.score = score

def run(self):
while 1:
RBL = self.__queue.get()
# Are we at the end of the queue?
if RBL is None: break
self.result = checkRBL("127.0.0.2",RBL,True,5)
score.addRBL(RBL,self.result[0],self.result[1])

queue = Queue.Queue(0)
score = ConnectionScore()

f = open("rbl.list",'r')
MEGARBL = []
while 1:
line = f.readline().strip()
if not line: break
MEGARBL.append(line)
f.close()


for i in range(WORKERS):
Worker(queue,score).start() # start a worker

for i in MEGARBL:
queue.put(i)

for i in range(WORKERS):
queue.put(None) # add end of queue marker

while 1:
# wait for the queue???
if queue.empty():
break
else:
time.sleep(0.1)


elapsed = time.time() - starttime
rate = len(MEGARBL)/elapsed
rate = str(round(rate,2))
elapsed = str(round(elapsed,2))

score.showRBL()
print "Checked",str(len(MEGARBL)),"zones in",elapsed,"seconds.
(",rate.strip(),"per second )"

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


Re: Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

2006-03-16 Thread [EMAIL PROTECTED]
Sorry to bring this up again, but I decided to try to re-create the
program, using the 2d array.


However, I ran into a slight problem.
How will the permutation function have to be modified?
I'm having issues trying to figure out how it works, and how it would
need to be modified to use it correctly (I used it from a cookbook, and
didn't bother figuring it out)

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


Re: Queue limitations?

2006-03-16 Thread Metalone
This example is missing a few initialization details although they can
possibly be inferred.
For example is
iq = imageQueue()
but imageQueue does not have a put() method.
Is SetQueue() called?
Is iq.start() called?

I like to see small, fully complete and tested examples.
The following works using strings as images.
It might prove interesting to modify this test case to use your image
objects instead of strings.

import Queue
import threading
import unittest

class imageQueue(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.filenum = 0
self.theQueue = Queue.Queue(-1)
self.done = False
self.results = []

def run(self):
while not self.done:
# for testing, do something simple with images
try:
img = self.theQueue.get(True, 1)
except:
pass
else:
self.results.append(img)
self.filenum += 1

def SetQueue(self, q_):
self.theQueue = q_

def stop(self):
self.done = True


class Tester(unittest.TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test_1(self):
# initialize
q = Queue.Queue()
iq = imageQueue()
iq.SetQueue(q)
iq.start()

# produce images
images = ["123", "456", "789"]
for x in images:
q.put(x)

# wait till all images consumed
while iq.filenum != 3:
pass

# stop the thread
iq.stop()

# assert that the consumer consumed what was produced
msg = "%s != %s" % (images, iq.results)
self.assert_(images == iq.results, msg)

if __name__ == '__main__':
unittest.main()

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


Is there a python library to parse C++ code file?

2006-03-16 Thread Allerdyce . John
Is there a python library to parse C++ code file?
If yes, can you please tell me where is it?

Thank you.

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


Re: python newbie, linux novice, needs to run spamassassin

2006-03-16 Thread Lonnie Princehouse
I don't know spamassassin's exact set up, but usually procmail spam
filters read an email message from standard input and produce an exit
code that tells you if the message is spam or not.

So from the Python side, it should be as easy as running whatever the
command is (a quick googling suggests it is "sa-filter"), feeding it
the message on stdin, and capturing the exit code.Have a look at
Python's os.system, os.popen2, or os.popen3 fuctions.  It may also be
the case that the filter emits  a modified version of the email on
stdout containing spam-filter related headers.

Also, I'd recommend spambayes above spamassassin.  Spambayes is a
statistical approach as opposed to Spamassassin's rule-based system*,
and for bonus point's it's written in Python.



* at this point someone will probably chime in saying it's possible to
rig spamassassin with a bayesian filter... probably so.  I haven't
looked at it in years.

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


How to search XML? Are there special libs?

2006-03-16 Thread Sullivan WxPyQtKinter
I am now using XML to record my lab records in quite a complex way, in
which about 80 tags are used to identify different types of data. I
think it is  a good idea to search for a popular and mature XML search
engine before I started to program it myself:

I need the following functions:
Search and get all the records that share the same tree structures.
Search records containing a specific node or sub tree structres.

Does anyone know about something suitable? Or other powerful XML search
engine in Python?
Thank you so much for help.

PS: I do not care about the learning curve, as long as it is not  a
cliff to climb.

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


Re: "pow" (power) function

2006-03-16 Thread Terry Reedy

"Mike Ressler" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I have a counterexample. In the original timeit example, 111**111 was
> used. When I run that
>
 timeit.Timer("pow(111,111)").timeit()
> 10.968398094177246
 timeit.Timer("111**111").timeit()
> 10.04007887840271
 timeit.Timer("111.**111.").timeit()
> 0.36576294898986816
>
> The pow and ** on integers take 10 seconds, but the float ** takes only
> 0.36 seconds. (The pow with floats takes ~ 0.7 seconds). Clearly
> typecasting to floats is coming in here somewhere. (Python 2.4.1 on
> Linux FC4.)

For floats, f**g == exp(log(f**g)) == exp(g*log(f)) (with maybe further 
algebraic manipulation, depending on the implementation).  The time for 
this should only be mildly dependent on the magnitudes of f and g.

The time for i**j, on the other hand, grows at least as fast as log(j).  So 
I should expect comparisons to depend on magnitudes, as you discovered.

Terry Jan Reedy




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


Re: accessing a USB HID

2006-03-16 Thread Serge Orlov
[EMAIL PROTECTED] wrote:
> I've been teaching myself Python as part of my senior design project at
> university.
>
> The obstacle our group currently faces is communicating with a
> microcontroller (ACS USB Servo II) that appears in Windows as a USD
> HID. Unfortunately, the vendor's sample code is in Visual Basic and
> Visual C++ which none of our group members have any experience using.
>
> My hope is that someone has experience with this type of problem and
> can point me to some reference material. At this point I'm a bit lost
> in the morass of USB terminology.
>
> While I'm at it... if anyone knows of a better way to approach this
> problem (serial or parallel microcontroller) or another language with
> better tools, I'd appreciate that as well. We're just trying to turn
> several motors on and off while polling some photodiodes and all this
> HID business seems like unnessary overkill.

After cursory look at the device home page it appears the vendor is
providing an Active X control. So it looks like you will need to learn
client side COM programming no matter what language you choose. For
Python you will need win32 extensions:
http://starship.python.net/crew/mhammond/win32/Downloads.html
or you can use ActivePython distribution that comes integrated with it.

Don't be scared by USB HID, it's just a mandatory classification of the
device under Windows, you don't need to deal with it. Python and COM
don't look scary:
http://www.python.org/windows/win32com/QuickStartClientCom.html

  -- Serge.

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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread [EMAIL PROTECTED]
-- The states are lists of regular expressions
-- where [a,b,..] means match a or b or...

I haven't run or studied your program yet myself but what I had in mind
was that the list of wc's are *all* to be excluded, so the list
[wc1..wcn] is to correspond generating all tuples matching not(wc1 and
.. and wcn).  Maybe you're already doing that. The wc's themselves
could be logical statements among the 'primitive' wc's.  That's why I
named it the 'wildcard exclusion problem'. It's a lot easier to specify
a list of simpler wc's than create a long logical expression.

Thanks to all who are making this an interesting thread.

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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Wade Humeniuk
Oops, problems cutting an pasting, should be,

;; Wade Humeniuk

(defclass odometer ()
   ((base :initform 0 :accessor base)
(meter :initform nil :accessor meter)
(n-digits :initarg :n-digits :accessor n-digits)
(digit-set :initarg :digit-set :accessor digit-set)))

(defmethod initialize-instance :after ((obj odometer) &rest initargs)
   (setf (base obj) (length (digit-set obj))
 (meter obj) (make-array (n-digits obj) :initial-element 0)
 (digit-set obj) (coerce (digit-set obj) 'vector)))

(defun inc-odometer (odometer)
   (loop with carry = 1
 for i from (1- (n-digits odometer)) downto 0
 for digit = (incf (aref (meter odometer) i) carry)
 if (= digit (base odometer)) do
   (setf (aref (meter odometer) i) 0)
   (setf carry 1)
 else do
   (setf carry 0)
 while (not (zerop carry

(defun zero-meter-p (odometer)
   (every #'zerop (meter odometer)))

(defmethod next-set ((obj odometer))
   (prog1 (map 'list (lambda (digit)
   (aref (digit-set obj) digit))
   (meter obj))
 (inc-odometer obj)))

(defclass cs-with-wc (odometer)
   ((exclusion :initarg :exclusion :accessor exclusion)
(at-end :initform nil :accessor at-end)))

(defmethod next-set ((obj cs-with-wc))
   (tagbody
:next
(unless (at-end obj)
  (let ((set (call-next-method)))
(when (zero-meter-p obj) (setf (at-end obj) t))
(if (not (funcall (exclusion obj) set))
(return-from next-set set)
  (go :next))

(defun print-all-cs (set length exclusion)
   (let ((cs-with-wc (make-instance 'cs-with-wc :n-digits length :digit-set set
:exclusion exclusion)))
 (loop for set = (next-set cs-with-wc)
   while set do (print set

CL-USER 7 > (print-all-cs '(a b) 3 (lambda (set)
  (destructuring-bind (x y z)
  set
(or (and (eql x 'a) (eql z 'b))
(and (eql x 'b) (eql z 'a))

(A A A)
(A B A)
(B A B)
(B B B)
NIL

CL-USER 8 > (print-all-cs '(abc xyz) 3 (lambda (set)
  (and (eql (first set) 'abc)
   (eql (third set) 'xyz

(ABC ABC ABC)
(ABC XYZ ABC)
(XYZ ABC ABC)
(XYZ ABC XYZ)
(XYZ XYZ ABC)
(XYZ XYZ XYZ)
NIL

CL-USER 9 >
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Wade Humeniuk
[EMAIL PROTECTED] wrote:
> What I have in mind is the efficient,  generation of the
> complement S^n/WC(S^n). A good program should initialize, generate, and
> terminate.
> 
> T=cartprodex(S,n,WC); //initialize
> for all i in T do
>   what you want with i
>   test to see if any more
>   terminate if not
> 
> and it should do this without explicitly generating WC and then
> complementing. For example, if the cardinality of S is m, and the WC is
> just '*a*b*', with a != b, then EX(S^n):=S^n\WC(S^n) has cardinality
> (m-1)^(n-1)*(m+n-1). Specifically, if m=5 and n=10, then |EX|=3670016
> while |S^10|=9765625, so that |EX|/|S^10| is about 0.3758. In general
> the program should directly generate EX from arbitrary WC. Of course,
> in practice the WC should themselves occur in a logically consistent
> manner, but let's just assume they're a given.
> 

Another attempt.  I have made no special attempt to create an
exclusion language, just used an anonymous lambda predicate.


;; Wade Humeniuk

(defclass odometer ()
   ((base :initform 0 :accessor base)
(meter :initform nil :accessor meter)
(n-digits :initarg :n-digits :accessor n-digits)
(digit-set :initarg :digit-set :accessor digit-set)))

(defmethod initialize-instance :after ((obj odometer) &rest initargs)
   (setf (base obj) (length (digit-set obj))
 (meter obj) (make-array (n-digits obj) :initial-element 0)
 (digit-set obj) (coerce (digit-set obj) 'vector)))

(defun inc-odometer (odometer)
   (loop with carry = 1
 for i from (1- (n-digits odometer)) downto 0
 for digit = (incf (aref (meter odometer) i) carry)
 if (= digit (base odometer)) do
   (setf (aref (meter odometer) i) 0)
   (setf carry 1)
 else do
   (setf carry 0)
 while (not (zerop carry

(defun zero-meter-p (odometer)
   (every #'zerop (meter odometer)))

(defmethod next-set ((obj odometer))
   (prog1 (map 'list (lambda (digit)
   (aref (digit-set obj) digit))
   (meter obj))
 (inc-odometer obj)))

(defclass cs-with-wc (odometer)
   ((exclusion :initarg :exclusion :accessor exclusion)
(at-end :initform nil :accessor at-end)))

(defmethod next-set ((obj odometer))
   (tagbody
:next
(unless (at-end obj)
  (let ((set (call-next-method)))
(when (zero-meter-p obj) (setf (at-end obj) t))
(if (not (funcall (exclusion obj) set))
(return-from next-set set)
  (go :next))

(defun print-all-cs (set length exclusion)
   (let ((cs-with-wc (make-instance 'cs-with-wc :n-digits length :digit-set set
:exclusion exclusion)))
 (loop for set = (next-set cs-with-wc)
   while set do (print set

CL-USER 134 > (cs-with-wc '(a b) 3 (lambda (set)
  (destructuring-bind (x y z)
  set
(or (and (eql x 'a) (eql z 'b))
(and (eql x 'b) (eql z 'a))

(A A A)
(A B A)
(B A B)
(B B B)
NIL

CL-USER 135 > (cs-with-wc '(a b) 3 (lambda (set)
  (eql (second set) 'a)))

(A B A)
(A B B)
(B B A)
(B B B)
NIL

CL-USER 136 > (cs-with-wc '(abc xyz) 3 (lambda (set)
  (and (eql (first set) 'abc)
   (eql (third set) 'xyz

(ABC ABC ABC)
(ABC XYZ ABC)
(XYZ ABC ABC)
(XYZ ABC XYZ)
(XYZ XYZ ABC)
(XYZ XYZ XYZ)
NIL
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python / glade fundamentals

2006-03-16 Thread Dave Cook
On 2006-03-16, Doug <[EMAIL PROTECTED]> wrote:

> Can someone tell me why I do not get a connection between the events and
> the functions in the sample below.  GUI window appears OK, just no
> connections seem to be made.
> I am new to this so may be missing something fundamental. 

This might be relevant:

http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq03.003.htp

Dave Cook
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Dan Piponi
Is this Haskell implementation what you want? It does the wildcard
matching through a state machine and it essentially threads the
state machine through the cartesian product, switching to the
ordinary cartesian product when possible as an optimisation.
The execution of the state machine is shared by strings with the
same prefix making it reasonably efficient even though the state
machine itself isn't optimised.

If it doesn't work, I'm sure it's only a few typos away...

-- generate strings of length n from alphabet l such that
-- the state machine, with transition function t, is not on
-- a final state (determined by function f) at the
-- end of the string.
-- If the state is ever 'unmatchable' (as determined by u)
-- we just return the cartesian product as no rejection
-- can take place.
generate f u t s 0 l = if f s then [] else [[]]
generate f u t s n l | u s = sequence (replicate n l)
 | otherwise =
 [a:b | a <- l, let s' = t s a,
b <- generate f u t s' (n-1) l]

-- The states are lists of regular expressions
-- where [a,b,..] means match a or b or...

-- This is the transition function for our machine.
transition pat a = pat >>= d a where
-- Brzozowski derivative
d a [] = []
d a p@('*':pat) = p:d a pat
d a (p:pat) | a==p = [pat]
| otherwise = []

-- A terminal state is one that matches the null string
terminal p = or $ map terminal' p where
terminal' "" = True
terminal' ('*':p) = terminal' p
terminal' _ = False

run n alphabet pat =
generate terminal null transition [pat] n alphabet

test = run 3 "abc" "aa*a"

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


Re: Cheese Shop: some history for the new-comers

2006-03-16 Thread Paul Boddie
Fredrik Lundh wrote:
>
> since when is Microsoft a programming language ?

Well, to many a recruiter or middle-manager it almost is a kind of
programming language, given their often vague usage of that and other
product and technology names. But anyway, people who call themselves
"Java developers", for example, who respond to job adverts which read
"Java developers", and who might even surf over to python.org to check
out what this Python thing is all about, might well see the label
"developer" or "developers" and think, "That's me!" And, as if I'd
arranged it to make the point, on java.sun.com the main heading
reads...

Java.sun.com: The Source for Java Developers

I guess java.sun.com isn't just for Sun's internal Java development
team after all.

Paul

P.S. The issue is whether python.org is trying to be the kind of site
java.sun.com is, appealing to developers in general (ie. people who
aren't working on open source language runtime implementations). Yes, I
know: what would non-developers be doing looking at a programming
language Web site? Well, the Java site touches on that as well, in a
brand promotion kind of way - do you remember "Python Powered"?

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


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-16 Thread Xah Lee
Xah Lee wrote:
« The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations
 http://xahlee.org/UnixResource_dir/writ/notations.html »

A side note: the terminology “Algebraic” Notation is a misnomer. It
seems to imply that such notations have something to do with the branch
of math called algebra while other notation systems do not. The reason
the name Algebraic Notation is used because when the science of algebra
was young, around 1700s mathematicians are dealing with equations using
symbols like “+ × =” written out similar to the way we use them
today. This is before the activities of systimatic investigation into
notation systems as necessitated in the studies of logic in 1800s or
computer languages in 1900s. So, when notation systems are actually
invented, the conventional way of infixing “+ × =” became known as
algebraic because that's what people think of when seeing them.

   Xah
   [EMAIL PROTECTED]
 ∑ http://xahlee.org/

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

accessing a USB HID

2006-03-16 Thread jodansmif
I've been teaching myself Python as part of my senior design project at
university.

The obstacle our group currently faces is communicating with a
microcontroller (ACS USB Servo II) that appears in Windows as a USD
HID. Unfortunately, the vendor's sample code is in Visual Basic and
Visual C++ which none of our group members have any experience using.

My hope is that someone has experience with this type of problem and
can point me to some reference material. At this point I'm a bit lost
in the morass of USB terminology.

While I'm at it... if anyone knows of a better way to approach this
problem (serial or parallel microcontroller) or another language with
better tools, I'd appreciate that as well. We're just trying to turn
several motors on and off while polling some photodiodes and all this
HID business seems like unnessary overkill.

Any assistance much appreciated,
Jordan

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


Re: My Generator Paradox!

2006-03-16 Thread [EMAIL PROTECTED]

vbgunz wrote:
> I am afraid that this is the first time in which I would probably need
> something explained to me as if I were a little child. I am having a
> hard time getting this through my thick skull. What in the world is
> wrong with this!?
>
> ''' ### '''
>
> def generatorFunction(sequence=['item1', 'item2', 'item3']):
> for item in sequence:
> yield item
>
> yieldedValue = generatorFunction()
>
> '''this seems to work perfectly.'''
> print '-' * 32
> print yieldedValue  # 
> print yieldedValue.next()   # item1
> print yieldedValue.next()   # item2
> print yieldedValue.next()   # item3
>
> '''this is where things don't make any sense!'''
> print '-' * 32
> print generatorFunction()   # 
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
>
> ''' ### '''
>
> the first set of calls assigned to yieldedValue work but the second set
> without assignment don't.  I asked for help on this at #python (I love
> those people in there!) and was told the following...
> generatorFunction() is a call (obvious) when calling the second set, I
> am resetting the iteration and this explains why I only and always get
> item1.
>
> ok. *but* why in the world does the first set of calls work?
> technically, isn't yieldedValue == generatorFunction() on a name basis?
> I mean isn't the following technically the same?
>
> generatorFunction()
> yieldedValue = generatorFunction()

No. Look at this

>>> a = generatorFunction()
>>> b = generatorFunction()
>>> a==b
False

Why aren'y they the same? Here's a clue:

>>> generatorFunction()

>>> generatorFunction()


Note the addresses are different.

Try this

>>> b.next()
'item1'
>>> b.next()
'item2'
>>> generatorFunction().next()
'item1'

Just like your example, the generator re-initailized and
printed item1. But that's not the same generator as b

>>> b.next()
'item3'


>
> aren't they both the same? To me they should be but obviously this
> creates the point of this paradox. I don't understand what is happening
> here... Can someone care to explain why the assignment works but not
> the direct call? In a sense shouldn't the assignment yield the same
> results as the direct call and vice versa? I am confused :(
> 
> Thank you for any help on this!

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


Re: "pow" (power) function

2006-03-16 Thread Ben Cartwright
Mike Ressler wrote:
> >>> timeit.Timer("pow(111,111)").timeit()
> 10.968398094177246
> >>> timeit.Timer("111**111").timeit()
> 10.04007887840271
> >>> timeit.Timer("111.**111.").timeit()
> 0.36576294898986816
>
> The pow and ** on integers take 10 seconds, but the float ** takes only
> 0.36 seconds. (The pow with floats takes ~ 0.7 seconds). Clearly
> typecasting to floats is coming in here somewhere. (Python 2.4.1 on
> Linux FC4.)


No, there is not floating point math going on when the operands to **
are both int or long.  If there were, the following two commands would
have identical output:

  >>> 111**111
  107362012888474225801214565046695501959850723994224804804775911
  17562507619578334702249122617009363462146610374309298696786
  330067310159463303558666910091026017785587295539622142057315437
  069730229375357546494103400699864397711L
  >>> int(111.0**111.0)
  107362012888474224720018046104893130890742038145054486592605938
  348914231670972887594279283213585412743799339280552157756096410
  839752020853099983680499334815422669184408961411319810030383904
  886446681757296875373689157536249282560L

The first result is accurate.  Work it out by hand if you don't believe
me. ;-)  The second suffers from inaccuracies due to floating point's
limited precision.

Of course, getting exact results with huge numbers isn't cheap,
computationally.  Because there's no type in C to represent arbitrarily
huge numbers, Python implements its own, called "long".  There's a fair
amount of memory allocation, bit shifting, and other monkey business
going on behind the scenes in longobject.c.

Whenever possible, Python uses C's built-in signed long int type (known
simply as "int" on the Python side, and implemented in intobject.c).
On my platform, C's signed long int is 32 bits, so values range from
-2147483648 to 2147483647.  I.e., -(2**31) to (2**31)-1.

As long as your exponentiation result is in this range, Python uses
int_pow().  When it overflows, long_pow() takes over.  Both functions
use the binary exponentiation algorithm, but long_pow() is naturally
slower:

  >>> from timeit import Timer
  >>> Timer('2**28').timeit()
  0.24572032043829495
  >>> Timer('2**29').timeit()
  0.25511642791934719
  >>> Timer('2**30').timeit()
  0.27746782979170348
  >>> Timer('2**31').timeit()  # overflow: 2**31 > 2147483647
  2.8205724462504804
  >>> Timer('2**32').timeit()
  2.2251812151589547
  >>> Timer('2**33').timeit()
  2.406713399635

Floating point is a whole 'nother ball game:

  >>> Timer('2.0**30.0').timeit()
  0.33266301963840306
  >>> Timer('2.0**31.0').timeit()  # no threshold here!
  0.33437446769630697

--Ben

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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread [EMAIL PROTECTED]
The asterisk '*' matches any sequence of elements, not just one
element. The wildcard '*1*2*' would then correspond to a tuple with a 1
preceding a 2 in any positions. The wc '1*2' would correspond to a
starting 1 and an ending 2 with anything in between. The wc *12* would
correspond to a 1 adjacent to a 2 with the pair in any position.
Possibilities like '*a*a*b*'  and '*a*a*a*' of any length are also
allowed. If n is the dimension, then any n-tuple wc is just a point. My
apologies for the confusion.

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


Re: My Generator Paradox!

2006-03-16 Thread Schüle Daniel
it's easy to explain

class X:
pass

x=X()
y=X()

x and y are different instances
one can put in x
x.item = 1
y doesn't even have an attribute item for example

similar with generators
they are *different* objects of same kind generator

 >>> def fib():
... a,b = 1,1
... while True:
... a,b = b,a+b
... yield a,b
...
 >>> f1 = fib()
 >>> f2 = fib()
 >>> f1

 >>> f2
# different addresses
 >>> f1 is f2
False
 >>> f1.next()
(1, 2)
 >>> f1.next()
(2, 3)
 >>> f1.next()
(3, 5)
 >>>
 >>>
 >>> f2.next()
(1, 2)
 >>>

it's only natural that each objects starts it's own fibonaci serie

hth, Daniel

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


Re: My Generator Paradox!

2006-03-16 Thread David Wahler
vbgunz wrote:
> I am afraid that this is the first time in which I would probably need
> something explained to me as if I were a little child. I am having a
> hard time getting this through my thick skull. What in the world is
> wrong with this!?
>
> ''' ### '''
>
> def generatorFunction(sequence=['item1', 'item2', 'item3']):
> for item in sequence:
> yield item
>
> yieldedValue = generatorFunction()
>
> '''this seems to work perfectly.'''
> print '-' * 32
> print yieldedValue  # 
> print yieldedValue.next()   # item1
> print yieldedValue.next()   # item2
> print yieldedValue.next()   # item3
>
> '''this is where things don't make any sense!'''
> print '-' * 32
> print generatorFunction()   # 
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
>
> ''' ### '''
>
> the first set of calls assigned to yieldedValue work but the second set
> without assignment don't.  I asked for help on this at #python (I love
> those people in there!) and was told the following...
> generatorFunction() is a call (obvious) when calling the second set, I
> am resetting the iteration and this explains why I only and always get
> item1.
>
> ok. *but* why in the world does the first set of calls work?
> technically, isn't yieldedValue == generatorFunction() on a name basis?
> I mean isn't the following technically the same?
>
> generatorFunction()
> yieldedValue = generatorFunction()
>
> aren't they both the same?
[snip]

In that short example, they happen to be different, but equivalent,
objects, but that will not always be the case. Consider this:

>>> a = generatorFunction()
>>> b = generatorFunction()
>>> print a.next()
item1

Now a and b are both generators for generatorFunction, but calling
a.next() again will return 'item2', while calling b.next() will return
'item1'. The value returned by generatorFunction is an object, which
has an internal state that makes it distinct from other objects of the
same type. So once your yieldedValue has been altered by calling the
next() method, it is no longer equivalent to a fresh instance of the
generator.

-- David

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


Re: My Generator Paradox!

2006-03-16 Thread Michal Kwiatkowski
vbgunz wrote:
> def generatorFunction(sequence=['item1', 'item2', 'item3']):
> for item in sequence:
> yield item
> 
> yieldedValue = generatorFunction()

You're creating an iterator here and binding it to name yieldedValue
(which is bogus, it should be named valueGenerator or sth like that).

> '''this seems to work perfectly.'''
> print '-' * 32
> print yieldedValue  # 
> print yieldedValue.next()   # item1
> print yieldedValue.next()   # item2
> print yieldedValue.next()   # item3

You're calling your iterator's next() method getting all of values, as
expected.

> '''this is where things don't make any sense!'''
> print '-' * 32
> print generatorFunction()   # 
You're creating a new iterator here.

> print generatorFunction().next()# item1
Another anonymous iterator gets created here. Instantly its next()
method is called, yielding first value.

> print generatorFunction().next()# item1
And so on...

> generatorFunction() is a call (obvious) when calling the second set, I
> am resetting the iteration and this explains why I only and always get
> item1.
> 
> ok. *but* why in the world does the first set of calls work?
> technically, isn't yieldedValue == generatorFunction() on a name
> basis? I mean isn't the following technically the same?
> 
> generatorFunction()
> yieldedValue = generatorFunction()

Well, first statement creates new iterator which is garbage collected
right away (as it has no bindings). Second statement creates an
iterator and binds it to name yieldedValue. Then it can be used as
typical iterator. Calling yieldedValue.next() just calls method of the
same iterator you've created a moment ago. It's still the same object.
The difference is like the difference between following two lines:

list()  # creating a new list
new_list = list()  # creating a new list and binding its name

So, rewriting your example from generator to dictionary objects:

alist = [1, 2, 3, 4, 5]
print alist   # [1, 2, 3, 4, 5]
print alist.pop() # 5
print alist.pop() # 4
print alist.pop() # 3

print [1, 2, 3, 4, 5]   # [1, 2, 3, 4, 5]
print [1, 2, 3, 4, 5].pop() # 5
print [1, 2, 3, 4, 5].pop() # 5
print [1, 2, 3, 4, 5].pop() # 5

Remember that generator is an object and you'll be fine.

mk
-- 
 . o .   >>  http://joker.linuxstuff.pl  <<
 . . o   It's easier to get forgiveness for being wrong
 o o o   than forgiveness for being right.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Generator Paradox!

2006-03-16 Thread Felipe Almeida Lessa
Em Qui, 2006-03-16 às 16:17 -0800, vbgunz escreveu:
> print generatorFunction()   # 
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1
> print generatorFunction().next()# item1 

Each time you say "generatorFunction()", it gives you a new generator,
thus returning the first item again.

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

Converting to ARGB and writing to a bitmap

2006-03-16 Thread heathimself
Hi,
I don't know what type of files they are, but the script allows me to
save to a bitmap just fine. But I do know they need to be in RGBA 
format, so I've followed what most of the tutorials for RGBA
conversions said to do...shifting the bytes.

The major problem is that everything is in green, it's shifted up by x
pixels, and it's..um..flipped from left to right. I've been working on
this for a few weeks now and any insight to the problem is greatly
appreciated.

http://www.geocities.com/fisherdude_99/TestImg.zip


import struct
import sys
import Image


if len(sys.argv) < 3:
   print "usage: tobmp.py  "
   sys.exit(1)

width = int(sys.argv[2])

f1 = open(sys.argv[1], "rb")
f1.seek(0, 2)
size = f1.tell()
f1.seek(0)

### write BITMAPFILEHEADER ###
f2 = open(sys.argv[1] + ".bmp", "wb")
f2.write("BM")

bfSize = size+54
f2.write(struct.pack("L", bfSize))

# bfReserved1 and 2
f2.write("\x00\x00\x00\x00")

bfOffBits = 54
f2.write(struct.pack("L", bfOffBits))

### write BITMAPINFOHEADER ###
biSize = 40
f2.write(struct.pack("L", biSize))

biWidth = width
f2.write(struct.pack("L", biWidth))

biHeight = (size/ 2/ width)
f2.write(struct.pack("L", biHeight))

biPlanes = 1
f2.write(struct.pack("H", biPlanes))

biBitCount = 32
f2.write(struct.pack("H", biBitCount))

# biCompression
f2.write("\x00\x00\x00\x00")

# biSizeImage
f2.write("\x00\x00\x00\x00")

# biXPelsPerMeter
f2.write("\x00\x00\x00\x00")

# biYPelsPerMeter
f2.write("\x00\x00\x00\x00")

# biClrUsed
f2.write("\x00\x00\x00\x00")

# biClrImportant
f2.write("\x00\x00\x00\x00")

### write the bitmap data ###
print f2.tell() ##must be 54

# since bitmaps are upside down, gotta flip it over
data = f2.read()

i = size-21
while i >= 0:
nm = 0x100

f1.seek(i)
temp1 = struct.unpack('B', f1.read(1))[0]

peek = temp1

a = nm*(peek >> 24) & 0xff
r = nm*(peek >> 16) & 0xff
g = nm*(peek >> 8 ) & 0xff
b = nm*(peek & 0xff)

sh = (a<<24)|(r<<16)|(g<<8)|b

f2.write(struct.pack('H', sh))
i -= 1

f1.close()
f2.close()


Usage: bmpcon.py testimg 100

Thanks a lot

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


My Generator Paradox!

2006-03-16 Thread vbgunz
I am afraid that this is the first time in which I would probably need
something explained to me as if I were a little child. I am having a
hard time getting this through my thick skull. What in the world is
wrong with this!?

''' ### '''

def generatorFunction(sequence=['item1', 'item2', 'item3']):
for item in sequence:
yield item

yieldedValue = generatorFunction()

'''this seems to work perfectly.'''
print '-' * 32
print yieldedValue  # 
print yieldedValue.next()   # item1
print yieldedValue.next()   # item2
print yieldedValue.next()   # item3

'''this is where things don't make any sense!'''
print '-' * 32
print generatorFunction()   # 
print generatorFunction().next()# item1
print generatorFunction().next()# item1
print generatorFunction().next()# item1

''' ### '''

the first set of calls assigned to yieldedValue work but the second set
without assignment don't.  I asked for help on this at #python (I love
those people in there!) and was told the following...
generatorFunction() is a call (obvious) when calling the second set, I
am resetting the iteration and this explains why I only and always get
item1.

ok. *but* why in the world does the first set of calls work?
technically, isn't yieldedValue == generatorFunction() on a name basis?
I mean isn't the following technically the same?

generatorFunction()
yieldedValue = generatorFunction()

aren't they both the same? To me they should be but obviously this
creates the point of this paradox. I don't understand what is happening
here... Can someone care to explain why the assignment works but not
the direct call? In a sense shouldn't the assignment yield the same
results as the direct call and vice versa? I am confused :(

Thank you for any help on this!

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


python newbie, linux novice, needs to run spamassassin

2006-03-16 Thread Gates Danderhoff
The frustrating thing about running linux is that every time you look for
an example using a search engine, the guy writing it expects you to know
10 other utilities.

I have a very simple request regarding spamassain: I just need an example
of how to run it once you have downloaded one or more emails into a
folder.

I have a python script which runs poplib and is downloading emails into a
folder, say ~/mymailin.

Each time the script is run and emails have been downloaded into the
folder, I would like to run spamassassin to read through the emails in the
folder and check them for their spamminess and if they are spammy, it
should do whatever spamassassin does: add a header and move it to another
folder, say ~/myspam, or maybe ~/mygoodemail if it's not spammy?

There must be a simple spamassassin command that will do this, that I can
add to the python script and run using the cmdline facility, but, as
I say, all the examples I've seen have something to do with running
spamassassin with procmail, fetchmail, qmail and God knows what else.

Some day I'll learn all about procmail, but, for now, I like my little
python poplib script, and a simple spamassassin example should do the
trick.

Thank you for any help.

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


Re: TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'

2006-03-16 Thread Jay Parlar

On Mar 16, 2006, at 3:14 PM, Peter Bismuti wrote:
> Can anyone explain this error message? 
>
>  Traceback (most recent call last):
>    File "/acct/pjb9508/RAT/Scripts/PyQt/RatDialog.py", line 30, in  
> NewClipButton_clicked
>       
> self.rat.planeClip(self.o,"SQUARE"+str(self.squareCounter),width,origin 
> )
>    File "/acct/pjb9508/RAT/Scripts/PyQt/rat.py", line 12, in planeClip
>      plane1[1] = origin[1]-width
>  TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
>
>

It looks like origin[1] and 'width' are both tuples. Substraction is  
not defined on tuples. That's what the error message is saying at  
least:

"TypeError: unsupported operand type(s) for -:" -This means that the  
'-' operator received some bad types, types it doesn't know how to work  
with

"'tuple' and 'tuple'" - This means the two types it received were both  
tuples.

Jay P.

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


Re: how to get 20000 html pages content quickly from one server?

2006-03-16 Thread Bruno Desthuilliers
JuHui a écrit :
> in fact, I want to do a script to get news on others site.

Then ask the webmasters of theses sites if they do have a ress feed...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-16 Thread Jeffrey Schwab
SamFeltus wrote:
> """Not that Mr. Lee has ever shown much interest in feedback, but you
> pretty well have stick to vanilla ASCII to get your notation through
> unmangled on newsgroups."""
> 
> It is the 21st century, so having to do that oughta inspire some sort
> of well earned anti Unix rant...
> 
> :)

Not anti-Unix. 
Anti-failure-to-use-appropriate-datatypes-for-the-task-at-hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-16 Thread SamFeltus
"""Not that Mr. Lee has ever shown much interest in feedback, but you
pretty well have stick to vanilla ASCII to get your notation through
unmangled on newsgroups."""

It is the 21st century, so having to do that oughta inspire some sort
of well earned anti Unix rant...

:)

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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Marcin 'Qrczak' Kowalczyk
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> The python code below generates a cartesian product subject to any
> logical combination of wildcard exclusions. For example, suppose I want
> to generate a cartesian product S^n, n>=3, of [a,b,c,d] that excludes
> '*a*b*' and '*c*d*a*'. See below for details.

I'm afraid that different programs in this thread has understood the
asterisk differently: that it matches any single element, or that it
matches any sequence of elements.

-- 
   __("< Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recycling internationalized garbage

2006-03-16 Thread Ross Ridge
Martin v. Löwis wrote:
> So "valid" yes; "meaningful" no. Therefore, for all practical
> purposes, 8-bit single-byte characters sets *will not* produce
> byte sequences that are valid in UTF-8 (although they could -
> it just won't happen).
>
> > In fact I can't think of any multi-byte encoding that can't produce
> > valid UTF-8 byte sequence.
>
> The same reasoning applies for them.

While you're reasoning may apply to European single-byte character
sets, it doesn't apply as well to Far East multi-byte encodings.  Take
ISO 2202-JP (RFC 1468) for example where any string is valid UTF-8 as
far as Python is concerned.  About 1% of the EUC-JP encoded words and
phrases listed in EDICT, a Japanese-English dictionary decode as valid
UTF-8 strings.  I get similar results with CEDICT, a Chinese-English
dictionary, about 1% for the Big5 encoded version of the file and about
4.5% for the GB 2312 version.

It would be nearly impossible to find all the strings in in Freedb that
decode as UTF-8 but aren't really encoded in UTF-8, but they do exist.
One example I managed to find are the GB 2312 encoded TTITLE5 and
TTITLE13 records of disc id 020f5210.

   Ross Ridge

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


TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'

2006-03-16 Thread Peter Bismuti
Can anyone explain this error message?  

Traceback (most recent call last):
  File "/acct/pjb9508/RAT/Scripts/PyQt/RatDialog.py", line 30, in NewClipButton_clicked
    self.rat.planeClip(self.o,"SQUARE"+str(self.squareCounter),width,origin)
  File "/acct/pjb9508/RAT/Scripts/PyQt/rat.py", line 12, in planeClip
    plane1[1] = origin[1]-width
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
-- Peter Bismuti
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'Dialog.ui'
#
# Created: Thu Mar 16 09:42:22 2006
#  by: The PyQt User Interface Compiler (pyuic) 3.13
#
# WARNING! All changes made in this file will be lost!


from qt import *


class Dialog(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)

if not name:
self.setName("Dialog")


DialogLayout = QGridLayout(self,1,1,11,6,"DialogLayout")

layout14 = QVBoxLayout(None,0,6,"layout14")

layout13 = QHBoxLayout(None,0,6,"layout13")

self.ClipListView = QListView(self,"ClipListView")
self.ClipListView.addColumn(self.__tr("Column 1"))
layout13.addWidget(self.ClipListView)

self.ClipTextEdit = QTextEdit(self,"ClipTextEdit")
layout13.addWidget(self.ClipTextEdit)
layout14.addLayout(layout13)

layout10 = QHBoxLayout(None,0,6,"layout10")

layout9 = QVBoxLayout(None,0,6,"layout9")

layoutWidth = QHBoxLayout(None,0,6,"layoutWidth")

self.WidthLabel = QLabel(self,"WidthLabel")
layoutWidth.addWidget(self.WidthLabel)

self.WidthLineEdit = QLineEdit(self,"WidthLineEdit")
layoutWidth.addWidget(self.WidthLineEdit)
layout9.addLayout(layoutWidth)

layout5 = QVBoxLayout(None,0,6,"layout5")

self.OriginLabel = QLabel(self,"OriginLabel")
self.OriginLabel.setAlignment(QLabel.WordBreak | QLabel.AlignCenter)
layout5.addWidget(self.OriginLabel)

layoutX = QHBoxLayout(None,0,6,"layoutX")

self.XLabel = QLabel(self,"XLabel")
layoutX.addWidget(self.XLabel)

self.XLineEdit = QLineEdit(self,"XLineEdit")
layoutX.addWidget(self.XLineEdit)
layout5.addLayout(layoutX)

layoutY = QHBoxLayout(None,0,6,"layoutY")

self.YLabel = QLabel(self,"YLabel")
layoutY.addWidget(self.YLabel)

self.YLineEdit = QLineEdit(self,"YLineEdit")
layoutY.addWidget(self.YLineEdit)
layout5.addLayout(layoutY)

layoutZ = QHBoxLayout(None,0,6,"layoutZ")

self.ZLabel = QLabel(self,"ZLabel")
layoutZ.addWidget(self.ZLabel)

self.ZLineEdit = QLineEdit(self,"ZLineEdit")
layoutZ.addWidget(self.ZLineEdit)
layout5.addLayout(layoutZ)
layout9.addLayout(layout5)
layout10.addLayout(layout9)

self.ButtonGroup = QButtonGroup(self,"ButtonGroup")

self.CircleRadioButton = QRadioButton(self.ButtonGroup,"CircleRadioButton")
self.CircleRadioButton.setGeometry(QRect(20,50,56,21))

self.SquareRadioButton = QRadioButton(self.ButtonGroup,"SquareRadioButton")
self.SquareRadioButton.setGeometry(QRect(20,20,64,21))
self.SquareRadioButton.setChecked(1)
layout10.addWidget(self.ButtonGroup)
layout14.addLayout(layout10)

layout11 = QHBoxLayout(None,0,6,"layout11")

self.NewClipButton = QPushButton(self,"NewClipButton")
layout11.addWidget(self.NewClipButton)

self.DeleteClipButton = QPushButton(self,"DeleteClipButton")
layout11.addWidget(self.DeleteClipButton)

self.CloseButton = QPushButton(self,"CloseButton")
layout11.addWidget(self.CloseButton)
layout14.addLayout(layout11)

DialogLayout.addLayout(layout14,0,0)

self.languageChange()

self.resize(QSize(340,427).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)

self.connect(self.NewClipButton,SIGNAL("clicked()"),self.NewClipButton_clicked)
self.connect(self.DeleteClipButton,SIGNAL("clicked()"),self.DeleteClipButton_clicked)
self.connect(self.CloseButton,SIGNAL("clicked()"),self.CloseButton_clicked)


def languageChange(self):
self.setCaption(self.__tr("RAT"))
self.ClipListView.header().setLabel(0,self.__tr("Column 1"))
self.ClipListView.clear()
item = QListViewItem(self.ClipListView,None)
item.setText(0,self.__tr("New Item"))

self.WidthLabel.setText(self.__tr("Width/Radius"))
self.OriginLabel.setText(self.__tr("Origin"))
self.XLabel.setText(self.__tr("X"))
self.YLabel.setText(self.__tr("Y"))
self.ZLabel.setText(self.__tr("Z"))
self.ButtonGroup.setTitle(self.__tr("Clip Type"))
self.CircleRadioButton.setText(self.__tr("Circle"))
self.SquareRadioButton.setText(self.__tr("Square"))
self.NewClipButton.setText(self.__tr("Ne

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread sa
in k:

cp:{[c;n;p]+(n#c)_vs(!_ c^n)_dvl,/{2_sv+(,/,/:\:)/(),/:@[x;&x=-1;:[;!c]]}'p}

examples:

  cp[2;3;,0 -1 1]
(0 0 0
 0 1 0
 1 0 0
 1 0 1
 1 1 0
 1 1 1)

  cp[2;3;(0 -1 1;1 -1 0)]
(0 0 0
 0 1 0
 1 0 1
 1 1 1)

  cp[2;3;(0 -1 1;1 -1 1)]
(0 0 0
 0 1 0
 1 0 0
 1 1 0)

arguments of cp:

c = cardinality of the input set
n = power
p = list of patterns (-1 = wildcard)

the algorithm directly computes the target set.  in other words,
it does not generate the set, then filter the matches from the
target.

modifying cp to accept s instead of the cardinality of s,
patterns expressed in terms of elements of s, &c. adds nothing
of interest to the problem.

<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> The python code below generates a cartesian product subject to any
> logical combination of wildcard exclusions. For example, suppose I want
> to generate a cartesian product S^n, n>=3, of [a,b,c,d] that excludes
> '*a*b*' and '*c*d*a*'. See below for details.
>
> CHALLENGE: generate an equivalent in ruby, lisp, haskell, ocaml, or in
> a CAS like maple or mathematica.
>
> #---
> # Short algorithm description
> # using function _genAll the program generates
> # cartesian product without sets, which match
> # some wildcarts
> # Sets generation uses recursion ->
> # first of all sets will be generated with dimension 1 and than
> filtered through wildcarts
> # then sets will be generated with dimension 2 and filtered again
> # until the required set dimension is reached
> # Program avoids explicit generation of some part of CP sets
> # if the end of whildcart is asterics (*) and if the first part of
> whildcart (without astrics)
> # matches current set => then this set will be filtered out and won't
> be used in
> # higher dimension set generation
> # example *,1,*,2,* [1,2] dim = 10
> # by dimension 2 only arrays [1,1],[2,1],[2,2] are will be generated
> # => array [1,2] won't be used in next recursion levels
> #---
> # To obtaine result use function
> # CPWithoutWC first parameter is a list of any elements
> (char,int,string,class exemplar , any type)
> # secont param is CP dimension
> # other parameters are wildcarts => lists with any values then may
> include
> # special value ALL - asterics equivalent
> #Example of usage: command line
> # >>> import cartesianProduct as cp
> # >>> for i in cp.CPWithoutWC([1,2],3,[1,cp.ALL,2]):
> # print i
> # [1, 1, 1]
> # [1, 2, 1]
> # [2, 1, 1]
> # [2, 1, 2]
> # [2, 2, 1]
> # [2, 2, 2]
> # >>> for i in
> cp.CPWithoutWC(['a','b'],3,['a',cp.ALL,'b'],['b',cp.ALL,'a']):
> # print i
> # ['a', 'a', 'a']
> # ['a', 'b', 'a']
> # ['b', 'a', 'b']
> # ['b', 'b', 'b']
> # >>> for i in cp.CPWithoutWC([1,2],3,[1,cp.ALL,2],[2,cp.ALL,1]):
> #print i
> # [1, 1, 1]
> # [1, 2, 1]
> # [2, 1, 2]
> # [2, 2, 2]
> # >>>
> # >>> for i in cp.CPWithoutWC([1,2],121212,[1,cp.ALL],[2,cp.ALL,1]):
> #print i
> ##  execute immediately
> # >>>
> # if You don't want to print cp. before ALL and CPWithoutWC use import
> like this:
> # from cartesianProduct import ALL,CPWithoutWC
> # CPWithoutWC is a python generator. Which means that it returns values
>
> # immediately and generate next in next cycle.
> # Program example
> #
> ## from cartesianProduct import ALL,CPWithoutWC
> ## def main():
> ## for i in
> cp.CPWithoutWC(['a','b'],3,['a',cp.ALL,'b'],['b',cp.ALL,'a']):
> ## ## do what You want with current value
> ## .
> ## ## go back to for statement and generate new
> ## if __name__ == "__main__":
> ## main()
> #
> """
>  Using logical combinations of WC:
>  1) It's possible to pass on to the function CPWithoutWC
>any number of wildcarts after first two parameters, for example:
>CPWithoutWC([1,2],121212,[1,cp.ALL],[2,cp.ALL,1],...)
>where ... - is any other wildcart's additional function parameters.
>Number of additional WC is not limited.
>Function will filter out all combinations, which match any passed on
> WC.
>It's equal to WC1 | WC2 |  , where | is python analog of OR
> logical operations.
>  2) To use more complex WC combinations follow these steps
>a) First of all create all needed WC
>b) Then use operators |, & and braces () to create combinations
> required and then pass it on to function
>CPWithoutWCEx as the third parameter. Don't use "or" and "and"
> python statement, otherwise program will
>work improper. First two parameters of this function are the same as
> of CPWithoutWC function - set of
>elements and CP dimension. An example of what was described above in
> command line:
>>>> from cartesianProduct import ALL,CPWithoutWC,CPWithoutWCEx,WC
>>>> a = WC([ALL,1,ALL])
>>>> b = WC([ALL,2,ALL])
>>>> c = a & b #filter out all sets which match a and b
>>>> for i in CPWithoutWCEx([1,2],3,c) : print i
>  

TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'

2006-03-16 Thread Peter Bismuti
 Strange, I don't get this error when using pure Python, only when using PyQt.  

Can anyone tell me what is going on here?  Thanks!





 File "/acct/pjb9508/RAT/Scripts/PyQt/RatDialog.py", line 30, in NewClipButton_clicked
    self.rat.planeClip(self.o,"SQUARE"+str(self.squareCounter),width,origin)
  File "/acct/pjb9508/RAT/Scripts/PyQt/rat.py", line 12, in planeClip
    plane1[1] = origin[1]-width
TypeError: unsupported operand type(s) for -: 'tuple' and 'tuple'
-- Peter Bismuti
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'Dialog.ui'
#
# Created: Thu Mar 16 09:42:22 2006
#  by: The PyQt User Interface Compiler (pyuic) 3.13
#
# WARNING! All changes made in this file will be lost!


from qt import *


class Dialog(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)

if not name:
self.setName("Dialog")


DialogLayout = QGridLayout(self,1,1,11,6,"DialogLayout")

layout14 = QVBoxLayout(None,0,6,"layout14")

layout13 = QHBoxLayout(None,0,6,"layout13")

self.ClipListView = QListView(self,"ClipListView")
self.ClipListView.addColumn(self.__tr("Column 1"))
layout13.addWidget(self.ClipListView)

self.ClipTextEdit = QTextEdit(self,"ClipTextEdit")
layout13.addWidget(self.ClipTextEdit)
layout14.addLayout(layout13)

layout10 = QHBoxLayout(None,0,6,"layout10")

layout9 = QVBoxLayout(None,0,6,"layout9")

layoutWidth = QHBoxLayout(None,0,6,"layoutWidth")

self.WidthLabel = QLabel(self,"WidthLabel")
layoutWidth.addWidget(self.WidthLabel)

self.WidthLineEdit = QLineEdit(self,"WidthLineEdit")
layoutWidth.addWidget(self.WidthLineEdit)
layout9.addLayout(layoutWidth)

layout5 = QVBoxLayout(None,0,6,"layout5")

self.OriginLabel = QLabel(self,"OriginLabel")
self.OriginLabel.setAlignment(QLabel.WordBreak | QLabel.AlignCenter)
layout5.addWidget(self.OriginLabel)

layoutX = QHBoxLayout(None,0,6,"layoutX")

self.XLabel = QLabel(self,"XLabel")
layoutX.addWidget(self.XLabel)

self.XLineEdit = QLineEdit(self,"XLineEdit")
layoutX.addWidget(self.XLineEdit)
layout5.addLayout(layoutX)

layoutY = QHBoxLayout(None,0,6,"layoutY")

self.YLabel = QLabel(self,"YLabel")
layoutY.addWidget(self.YLabel)

self.YLineEdit = QLineEdit(self,"YLineEdit")
layoutY.addWidget(self.YLineEdit)
layout5.addLayout(layoutY)

layoutZ = QHBoxLayout(None,0,6,"layoutZ")

self.ZLabel = QLabel(self,"ZLabel")
layoutZ.addWidget(self.ZLabel)

self.ZLineEdit = QLineEdit(self,"ZLineEdit")
layoutZ.addWidget(self.ZLineEdit)
layout5.addLayout(layoutZ)
layout9.addLayout(layout5)
layout10.addLayout(layout9)

self.ButtonGroup = QButtonGroup(self,"ButtonGroup")

self.CircleRadioButton = QRadioButton(self.ButtonGroup,"CircleRadioButton")
self.CircleRadioButton.setGeometry(QRect(20,50,56,21))

self.SquareRadioButton = QRadioButton(self.ButtonGroup,"SquareRadioButton")
self.SquareRadioButton.setGeometry(QRect(20,20,64,21))
self.SquareRadioButton.setChecked(1)
layout10.addWidget(self.ButtonGroup)
layout14.addLayout(layout10)

layout11 = QHBoxLayout(None,0,6,"layout11")

self.NewClipButton = QPushButton(self,"NewClipButton")
layout11.addWidget(self.NewClipButton)

self.DeleteClipButton = QPushButton(self,"DeleteClipButton")
layout11.addWidget(self.DeleteClipButton)

self.CloseButton = QPushButton(self,"CloseButton")
layout11.addWidget(self.CloseButton)
layout14.addLayout(layout11)

DialogLayout.addLayout(layout14,0,0)

self.languageChange()

self.resize(QSize(340,427).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)

self.connect(self.NewClipButton,SIGNAL("clicked()"),self.NewClipButton_clicked)
self.connect(self.DeleteClipButton,SIGNAL("clicked()"),self.DeleteClipButton_clicked)
self.connect(self.CloseButton,SIGNAL("clicked()"),self.CloseButton_clicked)


def languageChange(self):
self.setCaption(self.__tr("RAT"))
self.ClipListView.header().setLabel(0,self.__tr("Column 1"))
self.ClipListView.clear()
item = QListViewItem(self.ClipListView,None)
item.setText(0,self.__tr("New Item"))

self.WidthLabel.setText(self.__tr("Width/Radius"))
self.OriginLabel.setText(self.__tr("Origin"))
self.XLabel.setText(self.__tr("X"))
self.YLabel.setText(self.__tr("Y"))
self.ZLabel.setText(self.__tr("Z"))
self.ButtonGroup.setTitle(self.__tr("Clip Type"))
self.CircleRadioButton.setText(self.__tr("Circle"))
self.SquareRadioButton.setText(self.__tr

Re: Cheese Shop: some history for the new-comers

2006-03-16 Thread Peter Decker
On 3/16/06, Terry Hancock <[EMAIL PROTECTED]> wrote:

> But the usual distinction (on any project web page) is
> "User" versus "Developer".
>
> Who is a "user" of Python? That would be you, right? It
> would be fairly silly to have a page only for people who
> have programs written in Python that they use (they're
> *your program*'s users, not *python*'s users).
>
> "Developer", in context, is clearly "one who *develops*
> python", not "one who *uses* python to develop programs".
>
> I don't see the ambiguity. I would be confused by the
> opposite usage.

After your long explanation, your POV makes some sense. However, no
one should be expected to read such an involved explanation before
understanding common terms.

I am a developer. Yes, I 'use' Python for my development work, but
that doesn't make me any less of a developer. A link for 'developers'
would make me think that it is something I should be interested in,
even if your long explanation was included next to the link (I
wouldn't be likely to read it - I *know* what a developer is).

--

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread funkyj
NOTE: I am a lisp newbie.  I'm sure our resident lisp experts can
create much better (both faster, shorter and clearer) solutions than
the one above.

Even I could have created something shorter but I thought it would be
fun to apply the "utility function" approach in decomposing the
problem.

  --jfc

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


Re: Counting nested loop iterations

2006-03-16 Thread Jeffrey Schwab
Derek Basch wrote:
>> Depending on the types of the containers in question, you could use:
>>
>>  len(zoo) * len(animal)
> 
> I think this would give me the total iterations but I wouldn't be able
> to get a running count. Correct?

Correct.  If you need a running count, maintain a counter (or enumerate()).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch

Carl Banks wrote:
> But even the clear version isn't as nearly clear and straightforward as
> the nested fors with the counter.  I wouldn't forsake that clarity just
> so it isn't "kludgy".
>
>
> Carl Banks

Yeah, looks like using the counters is clearer. Thanks for the opinions
everyone!

Derek Basch

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


Re: Python IDE: great headache....

2006-03-16 Thread Dag Fjeld Edvardsen
> Come to think of it, the only exception is probably that PyScripter
(AFAIK)
> does not provide conditional pause.

Quoting myself :)

But now it does! Conditional breakpoints were introduced in the
new version released on the 14th of March:
http://mmm-experts.com/

  -Dag


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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread funkyj
here is my version of the same.

REPL output:

CL-USER> (tests)


set  = (1 2)
n= 3
patterns = ((1 ANY 2))
---
(1 1 1)
(1 2 1)
(2 1 1)
(2 1 2)
(2 2 1)
(2 2 2)


set  = (A B)
n= 3
patterns = ((A ANY B) (B ANY A))
---
(A A A)
(A B A)
(B A B)
(B B B)


set  = (1 2)
n= 3
patterns = ((1 ANY 2) (2 ANY 1))
---
(1 1 1)
(1 2 1)
(2 1 2)
(2 2 2)
NIL
CL-USER>

source:

 cartesian products minus wildcard patterns per:

 >Newsgroups: comp.lang.lisp, etc...
 >Subject: Programming challenge: wildcard exclusion in cartesian
products
 >Date: 16 Mar 2006 03:14:23 -0800



(defun show-me (x) (format t "~A~%" x))

(defun set^n (fn set n &optional acc)
  "call `fn' on each permutation of `set' raised to the `n' power"
  (if (<= n 0)
  (funcall fn (reverse acc))
  (dolist (e set)
(set^n fn set (- n 1) (cons e acc)

;; test set^n by printing and visually inspecting the result
(defun pr-set^n (set n)   (set^n #'show-me set n))

;; curry `set^n' so that `fn' is the only parameter
(defun set^n-gen (set n)
  (lambda (fn) (set^n fn set n)))

(defun mk-matchl-p (pat-list)
  "return a function that tests a value against the patterns in
`pat-list'"
  (labels ((matchp (pat val)
 (cond ((null pat) t)
   ((or (eq (car pat) (car val))
(eq (car pat) :any))
(matchp (cdr pat) (cdr val))
(lambda (val)
  "predicate: return true if val matches any pattern in `pat-list'"
  (dolist (p pat-list)
(if (matchp p val)
(return t))

(defun not-fp (f-pred)
  "return the complement of predicate `f-pred'"
  (lambda (x) (not (funcall f-pred x

;; f-gen is a generator of the form returned by set^n-gen
(defun accumulate-if (f-gen f-pred)
  "accumulate values generated by f-gen that satisfy f-pred"
  (let (acc)
(funcall f-gen (lambda (x) (if (funcall f-pred x) (push x acc
(nreverse acc)))

;; `pr-set^n-withoutWC' is the lisp equivalent (more or less) of
;; python code:
;;   >>> for i in cp.CPWithoutWC(x,y,z): print i
(defun pr-set^n-withoutWC (set n pat-list)
  (format t "~%~%set  = ~A~%n= ~A~%patterns = ~A~%~A~%"
  set n pat-list "---")
  (dolist (e (accumulate-if (set^n-gen set n)
(not-fp (mk-matchl-p pat-list
(format t "~A~%" e)))

(defun tests ()
  "generate test output per the original problem examples"
  (pr-set^n-withoutWC '(1 2) 3 '((1 :any 2)))
  (pr-set^n-withoutWC '(a b) 3 '((a :any b) (b :any a)))
  (pr-set^n-withoutWC '(1 2) 3 '((1 :any 2) (2 :any 1

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


Re: Counting nested loop iterations

2006-03-16 Thread Carl Banks
Derek Basch wrote:
> What is the best way to count nested loop iterations? I can only figure
> to use an index but that seems kludgy.
>
> index = 0
> for animal in zoo:
> for color in animal:
> index += 1

I don't know if it's kludgy, but I do prefer to set counters in the for
statement whenever I can.  If I were using 2.4, I might try writing
something like:

for i,(animal,zoo) in enumerate((animal,zoo) for animal in zoo for
color in animal):
pass

or maybe break it down a little for clarity:

aciter = ((animal,zoo) for animal in zoo for color in animal)
for i,(animal,zoo) in enumerate(aciter):
pass

But even the clear version isn't as nearly clear and straightforward as
the nested fors with the counter.  I wouldn't forsake that clarity just
so it isn't "kludgy".


Carl Banks

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


Re: Python Debugger / IDE ??

2006-03-16 Thread Rowdy
Don Taylor wrote:
> Is there a free or low-cost version of Delphi for Windows available 
> anywhere?
> 


There used to be a Delphi 6 Personal Edition that was available free
(for non-commercial use).  You might still find it around somewhere.

Rowdy

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


Re: Counting nested loop iterations

2006-03-16 Thread Duncan Booth
Derek Basch wrote:

> index = 0
> for animal in zoo:
> for color in animal:
> index += 1
  # assuming there is something more goes here...
> 

You could do this, but it kind of depends what the loop *really* looks 
like:

for index, color in enumerate(color
  for animal in zoo
  for color in animal):
# the something more goes here.
pass


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


Re: Other languages for PVM

2006-03-16 Thread Ravi Teja
I did not mean the lack of interest on part of the developer. That was
explained here.
http://www.livelogix.net/logix/future-work.html
His complaints were Efficiency and Security.

I was wondering why the Python community did not show interest in this.
There is tremendous potential in this product. For example, web
frameworks and ORMs are well understood now and people constantly push
for more and more parsimonious representations. Logix makes writing
DSLs trivial with Lisp like ease without all the parentheses. What I am
surprised is why the framework authors did not leverage it yet.

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


Re: Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Well, there it is:

* Added support for Free Pascal Compiler (http://www.freepascal.org/)
and Lazarus Project (http://www.lazarus.freepascal.org/)
Thanks to Michiel du Toit ([EMAIL PROTECTED])

That was easy.   I just saw the new support for D2k6 recently.

thx Ravi
Caleb

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


Re: Counting nested loop iterations

2006-03-16 Thread Kent Johnson
Derek Basch wrote:
> Fredrik Lundh wrote:
>>(the real question here is of course why you need the counter.  what's
>>the loop doing?  if the code you posted is all you have, you can replace
>>it with index = sum(len(animal) for animal in zoo), but I assume you want
>>to do more stuff in there...)
>>
>>
> 
> 
> Yes, I am doing more. Your example assumes that all that animals have
> the same amount of colors.

No, it doesn't. Fredrik wrote
index = sum(len(animal) for animal in zoo)

The expression (len(animal) for animal in zoo) yields a sequence of the 
lengths of the individual animals; passing this to sum() gives the total 
count.

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


Re: Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Ravi Teja
I posted this a few days ago. According to the website
(http://mmm-experts.com/VersionHistory.aspx?ProductId=3), FPC support
has been added since version 3.29.

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


Re: Counting nested loop iterations

2006-03-16 Thread Caleb Hattingh
Hi Derek

I went for an embarrassingly long time without knowing about
"enumerate()".  It doesn't directly answer your question about counting
*within* nests, but I am going to tell you this on the off chance you
don't know yet (and apologies if you do):

This:

count = 0
for animal in zoo:
a = animal
anum = count
count = count + 1

IS a kludge, when you have this available to you:

for count, animal in enumerate(zoo):
a = animal
anum = count

I won't say how long it took me to start using list comprehensions :)

regards
Caleb

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


Binary python extensions with Free Pascal Compiler

2006-03-16 Thread Caleb Hattingh
Hi all

I want to write python extensions with FPC (Free Pascal Compiler,
http://www.freepascal.org).   In Delphi, this is trivially easy due to
the great work of the P4D (Python-for-Delphi, http://mmm-experts.com/)
guys;  however, when aiming for cross-platform binary extensions, that
strategy naturally doesn't work.

FPC has great cross-platform support, and to date I have written
library units that compile to .dlls (on win32) and .so's (on posix),
and then used these via ctypes.  This has worked very well, but for
certain applications I would prefer to create a new python type via
binary extension, rather than a python class with method wrappers
around library calls.  I could just use C, I guess, but I have a large
amount of pascal code that I would like to use, and I would prefer not
to fiddle with a C-binary extension intermediate.

I have explored the python.h header, and as expected, there appears to
be much use of the C standard library.   Using a tool that converts a C
header into an object pascal unit (intended to be the interface to
python.dll) gets me some of the way, but of course, calls to the C
stdlib don't get automatically translated into equivalent pascal-coded
functionality.  I'm afraid I am answering my own question here: is the
only way of getting this working to change all the stdlib calls in my
newly created pascal unit (created from python.h) to matching
functionality in pascal?

If there is another, simpler way I'm just not seeing, I would be glad
to hear it.

Regards
Caleb

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


Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch
> Depending on the types of the containers in question, you could use:
>
>   len(zoo) * len(animal)

I think this would give me the total iterations but I wouldn't be able
to get a running count. Correct?

Thanks for the reply,
Derek Basch

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


Re: accessing attributes when inheriting?

2006-03-16 Thread James Stroud
Peter J. Bismuti wrote:
> 
> How do you access attributes of a class when inheriting from it? Can't you 
> just say:
> 
> self.attribute?  
> 
> Help?!
> ...
> #!/usr/bin/python
> 
> from Dialog import Dialog
> import enscmd
> 
> class RatDialog(Dialog):
> def __init__(self,parent = Dialog,name = "RatDialog",modal = 0,fl = 0):
> Dialog.__init__(self)
> self.ClipListView.header().setLabel(0,self.__tr("Clips"))    self.ClipListView.clear()
> def CloseButton_clicked(self):
> self.close()
> 
> 
> 
> from qt import *
> 
> 
> class Dialog(QDialog):
> def __init__(self,parent = None,name = None,modal = 0,fl = 0):
> QDialog.__init__(self,parent,name,modal,fl)
> 
> if not name:
> self.setName("Dialog")
> 
> 
> DialogLayout = QGridLayout(self,1,1,11,6,"DialogLayout")
> 
> layout14 = QVBoxLayout(None,0,6,"layout14")
> 
> layout13 = QHBoxLayout(None,0,6,"layout13")
> 
> self.ClipListView = QListView(self,"ClipListView")
> self.ClipListView.addColumn(self.__tr("Column 1"))
> layout13.addWidget(self.ClipListView)
> 
> self.ClipTextEdit = QTextEdit(self,"ClipTextEdit")
> layout13.addWidget(self.ClipTextEdit)
> layout14.addLayout(layout13)
> 
> layout10 = QHBoxLayout(None,0,6,"layout10")
> 
> layout9 = QVBoxLayout(None,0,6,"layout9")
> 
> layoutWidth = QHBoxLayout(None,0,6,"layoutWidth")
> 
> self.WidthLabel = QLabel(self,"WidthLabel")
> layoutWidth.addWidget(self.WidthLabel)
> 
> self.WidthLineEdit = QLineEdit(self,"WidthLineEdit")
> layoutWidth.addWidget(self.WidthLineEdit)
> layout9.addLayout(layoutWidth)
> 
> layout5 = QVBoxLayout(None,0,6,"layout5")
> 
> self.OriginLabel = QLabel(self,"OriginLabel")
> self.OriginLabel.setAlignment(QLabel.WordBreak | QLabel.AlignCenter)
> layout5.addWidget(self.OriginLabel)
> 
> layoutX = QHBoxLayout(None,0,6,"layoutX")
> 
> self.XLabel = QLabel(self,"XLabel")
> layoutX.addWidget(self.XLabel)
> 
> self.XLineEdit = QLineEdit(self,"XLineEdit")
> layoutX.addWidget(self.XLineEdit)
> layout5.addLayout(layoutX)
> 
> layoutY = QHBoxLayout(None,0,6,"layoutY")
> 
> self.YLabel = QLabel(self,"YLabel")
> layoutY.addWidget(self.YLabel)
> 
> self.YLineEdit = QLineEdit(self,"YLineEdit")
> layoutY.addWidget(self.YLineEdit)
> layout5.addLayout(layoutY)
> 
> layoutZ = QHBoxLayout(None,0,6,"layoutZ")
> 
> self.ZLabel = QLabel(self,"ZLabel")
> layoutZ.addWidget(self.ZLabel)
> 
> self.ZLineEdit = QLineEdit(self,"ZLineEdit")
> layoutZ.addWidget(self.ZLineEdit)
> layout5.addLayout(layoutZ)
> layout9.addLayout(layout5)
> layout10.addLayout(layout9)
> 
> self.ButtonGroup = QButtonGroup(self,"ButtonGroup")
> 
> self.CircleRadioButton = 
> QRadioButton(self.ButtonGroup,"CircleRadioButton")
> self.CircleRadioButton.setGeometry(QRect(20,50,56,21))
> 
> self.SquareRadioButton = 
> QRadioButton(self.ButtonGroup,"SquareRadioButton")
> self.SquareRadioButton.setGeometry(QRect(20,20,64,21))
> self.SquareRadioButton.setChecked(1)
> layout10.addWidget(self.ButtonGroup)
> layout14.addLayout(layout10)
> 
> layout11 = QHBoxLayout(None,0,6,"layout11")
> 
> self.NewClipButton = QPushButton(self,"NewClipButton")
> layout11.addWidget(self.NewClipButton)
> 
> self.DeleteClipButton = QPushButton(self,"DeleteClipButton")
> layout11.addWidget(self.DeleteClipButton)
> 
> self.CloseButton = QPushButton(self,"CloseButton")
> layout11.addWidget(self.CloseButton)
> layout14.addLayout(layout11)
> 
> DialogLayout.addLayout(layout14,0,0)
> 
> self.languageChange()
> 
> self.resize(QSize(340,427).expandedTo(self.minimumSizeHint()))
> self.clearWState(Qt.WState_Polished)
> 
> 
> self.connect(self.NewClipButton,SIGNAL("clicked()"),self.NewClipButton_clicked)
> 
> self.connect(self.DeleteClipButton,SIGNAL("clicked()"),self.DeleteClipButton_clicked)
> 
> self.connect(self.CloseButton,SIGNAL("clicked()"),self.CloseButton_clicked)
> 
> 
> def languageChange(self):
> self.setCaption(self.__tr("RAT"))
> self.ClipListView.header().setLabel(0,self.__tr("Column 1"))
> self.ClipListView.clear()
> item = QListViewItem(self.ClipListView,None)
> item.setText(0,self.__tr("New Item"))
> 
> self.WidthLabel.setText(self.__tr("Width/Radius"))
> self.OriginLabel.setText(self.__tr("Origin"))
> self.XLabel.setText(self.__tr("X"))

Re: Counting nested loop iterations

2006-03-16 Thread Derek Basch

Fredrik Lundh wrote:

> what's kludgy with using a counter to count things ?

Ohhh, nothing in particular. Just seeing if there is a better way to do
it.

> (the real question here is of course why you need the counter.  what's
> the loop doing?  if the code you posted is all you have, you can replace
> it with index = sum(len(animal) for animal in zoo), but I assume you want
> to do more stuff in there...)
>
> 

Yes, I am doing more. Your example assumes that all that animals have
the same amount of colors. Not a bad assumption considering I didn't
say anything about that. Looks like good old counters are they way to
go then.

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


Re: Counting nested loop iterations

2006-03-16 Thread Jeffrey Schwab
Derek Basch wrote:
> What is the best way to count nested loop iterations? I can only figure
> to use an index but that seems kludgy.
> 
> index = 0
> for animal in zoo:
> for color in animal:
> index += 1

Depending on the types of the containers in question, you could use:

len(zoo) * len(animal)



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


accessing attributes when inheriting?

2006-03-16 Thread Peter J. Bismuti


How do you access attributes of a class when inheriting from it? Can't you 
just say:

self.attribute?  

Help?!
...
#!/usr/bin/python

from Dialog import Dialog
import enscmd

class RatDialog(Dialog):
def __init__(self,parent = Dialog,name = "RatDialog",modal = 0,fl = 0):
Dialog.__init__(self)
self.ClipListView.header().setLabel(0,self.__tr("Clips"))   

accessing attributes when inheriting?

2006-03-16 Thread Peter Bismuti
How do you access attributes of a class when inheriting from it? Can't you 
just say:

self.attribute?  

Help?!
...
#!/usr/bin/python

from Dialog import Dialog
import enscmd

class RatDialog(Dialog):
    def __init__(self,parent = Dialog,name = "RatDialog",modal = 0,fl = 0):
    Dialog.__init__(self)
    self.ClipListView.header().setLabel(0,self.__tr("Clips"))   

Re: Counting nested loop iterations

2006-03-16 Thread Fredrik Lundh
Derek Basch wrote:

> What is the best way to count nested loop iterations? I can only figure
> to use an index but that seems kludgy.
>
> index = 0
> for animal in zoo:
> for color in animal:
> index += 1

what's kludgy with using a counter to count things ?

(the real question here is of course why you need the counter.  what's
the loop doing?  if the code you posted is all you have, you can replace
it with index = sum(len(animal) for animal in zoo), but I assume you want
to do more stuff in there...)





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


Re: OCR question

2006-03-16 Thread Duncan Watson <[EMAIL PROTECTED]>
Excellent suggestion.  I found it.  I will see what I can do about some
edge detection to crop the images so that gocr has an easier time of
it.

Thanks
-Duncan

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


Python / glade fundamentals

2006-03-16 Thread Doug
Hi all,
Can someone tell me why I do not get a connection between the events and
the functions in the sample below.  GUI window appears OK, just no
connections seem to be made.
I am new to this so may be missing something fundamental. 
Thanks, 
Doug



file pgtest.glade
=

 
http://glade.gnome.org/glade-2.0.dtd";>




  True
  GDK_KEY_PRESS_MASK
  PGtestWindow
  GTK_WINDOW_TOPLEVEL
  GTK_WIN_POS_NONE
  False
  640
  480
  True
  True
  True
  False
  False
  GDK_WINDOW_TYPE_HINT_NORMAL
  GDK_GRAVITY_NORTH_WEST
  

  

  True
  GDK_KEY_PRESS_MASK
  GDK_EXTENSION_EVENTS_ALL
  
  

  




file pgtest.py
==
import gtk
import gtk.glade

def on_drawingarea1_key_press(widget):
   print "keypress"   

xml = gtk.glade.XML('pgtest.glade')
widget = xml.get_widget('drawingarea1')
#print type(xml)

xml.signal_autoconnect({
  "on_drawingarea1_key_press_event": on_drawingarea1_key_press,
  "on_page_destroy_event":gtk.mainquit
})

gtk.main()


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


Counting nested loop iterations

2006-03-16 Thread Derek Basch
What is the best way to count nested loop iterations? I can only figure
to use an index but that seems kludgy.

index = 0
for animal in zoo:
for color in animal:
index += 1

Thanks,
Derek Basch

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


Re: Cheese Shop -> BSOL?

2006-03-16 Thread Christos Georgiou
On 11 Mar 2006 03:22:42 -0800, rumours say that "Paul Boddie"
<[EMAIL PROTECTED]> might have written:

>Tim Churches wrote:

>> Would it be possible to rename "Cheese Shop" as "Bright Side of Life"?

[Paul]


>So should a service for finding Python packages have a distinct
>identity? It is possible that a package index could be someone's
>principal view of the Python world ("I go to Camelot to get... what is
>it I get there?"), but the things that emerge from such a service
>aren't just downloads that have little in common with each other.
>Consequently, I don't think a descriptive name, derived from the name
>of the technology, is sensibly avoided in this case.

I like the BSOL idea, but in that case what will the package extension be
instead of .egg?  camelot.python.org has the advantage of suggesting an
obvious extension: .graal

So you go to the Camelot to get the graal (or one of them :).  In case this
catches on, I'd like to upload ASAP one of my packages [1] called "wholy".

PS "Grail" was a web browser written in Python (or an attempt at one).


[1] It's mostly useless but I trust wholy.graal will be downloaded by
millions.
-- 
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread [EMAIL PROTECTED]
What I have in mind is the efficient,  generation of the
complement S^n/WC(S^n). A good program should initialize, generate, and
terminate.

T=cartprodex(S,n,WC); //initialize
for all i in T do
  what you want with i
  test to see if any more
  terminate if not

and it should do this without explicitly generating WC and then
complementing. For example, if the cardinality of S is m, and the WC is
just '*a*b*', with a != b, then EX(S^n):=S^n\WC(S^n) has cardinality
(m-1)^(n-1)*(m+n-1). Specifically, if m=5 and n=10, then |EX|=3670016
while |S^10|=9765625, so that |EX|/|S^10| is about 0.3758. In general
the program should directly generate EX from arbitrary WC. Of course,
in practice the WC should themselves occur in a logically consistent
manner, but let's just assume they're a given.

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


Re: Executing a DOS program from within Python

2006-03-16 Thread iapain
Use os.system and if you wanna get rid of console window use subprocess
as gary said, you could have better options like killing proc if it
hang/stuck using win32api (if you are using windows) else process
timeout.

ret = os.system('sample.exe') # ret will have return code and os.system
execute sample.exe

#using subprocess

import subprocess
process = subprocess.Popen('sample.exe', stdout=subprocess.PIPE)
#you can print error/output using stderr/stdout pipe

Both are easy to implement!
Thanks!!

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


Re: Cheese Shop: some history for the new-comers

2006-03-16 Thread Fredrik Lundh
Paul Boddie wrote:

> > one of the richest people on earth did define what developers are:
> >
> > http://www.ntk.net/ballmer/mirrors.html
>
> I was wondering when someone would mention the "developers, developers,
> developers" Ballmer song-and-dance incident: clearly, he isn't chanting
> about internal Microsoft project teams.

since when is Microsoft a programming language ?





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


Re: email package 4.0a2

2006-03-16 Thread Tony Meyer
[Barry Warsaw]
>> I'm happy to announce the release of the email 4.0a2 standalone
>> package.

[Konrad Hinsen]
> My interpretation of the above paragraph is that it will be
> impossible to write Python code using the email module (and possibly
> other evolving modules) that works with both Python 2.4 and Python
> 2.6.

No, that's not correct.

try:
 from email import message
except ImportError:
 # Compat with 2.4 and earlier
 from email import Message as message

(etc)

Note also that 2.5 won't be out until late this year; 2.6 will  
probably be something like mid 2008.  That's a long time after 2.4  
(or 2.3, or 2.2).  If you want to support something like 10 years of  
versions, there will be difficulties doing that.  You can always  
bundle up the email package separately (this is extremely easy),  
however, so that users have email 4.0 and Python 2.2.

=Tony.Meyer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Wade Humeniuk
Without much testing.  Common Lisp

Pattern exclusions are made lispy.


(defun all-lists (list length)
   (unless (zerop length)
 (if (= length 1) (mapcar #'list list)
   (loop for elt in list
 nconc
 (mapcar (lambda (rest)
   (cons elt rest))
 (loop for rest on list
   nconc (all-lists rest (1- length

(defun cp-without-wc (source-list &rest patterns)
   (let* ((length (length (first patterns)))
  (all-lists (all-lists source-list length)))
 (dolist (pattern patterns)
   (setf all-lists
 (set-difference all-lists
 (mapcar (lambda (insertion)
   (let ((cp (copy-list pattern)))
 (loop for place on cp
   when (eql :any (car place)) do
   (setf (car place) (pop 
insertion)))
 cp))
 (all-lists source-list (count :any 
pattern)))
 :test #'equal)))
 (remove-duplicates all-lists :test #'equal)))

CL-USER 22 > (cp-without-wc '(a b) '(a :any b) '(b :any a))
((A A A) (A B A) (B A B) (B B B))

CL-USER 23 > (cp-without-wc '(abc xyz) '(abc :any xyz))
((XYZ XYZ XYZ) (XYZ XYZ ABC) (XYZ ABC XYZ) (XYZ ABC ABC) (ABC XYZ ABC) (ABC ABC 
ABC))

CL-USER 24 > (cp-without-wc '(a b) '(a :any :any))
((B B B) (B B A) (B A B) (B A A))

CL-USER 25 > (cp-without-wc '(a b) '(a :any :any) '(b :any :any))
NIL

CL-USER 26 > (cp-without-wc '(a b) '(:any :any b))
((B B A) (B A A) (A B A) (A A A))

CL-USER 27 >

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


Re: Is Forth for real?

2006-03-16 Thread astrobe

[EMAIL PROTECTED] a écrit :

> rickman wrote:
> > The original post seems to be missing, but my answer to the title
> > question is, No, Forth is not real.
>
> Not for real, for Integer.

No, it's for me and you (well, perhaps more for you than for me).
But 4IM is forever mine :)

 Amicalement,
  Astrobe

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


Re: Cheese Shop: some history for the new-comers

2006-03-16 Thread Paul Boddie
Harald Armin  Massa wrote:
>
> one of the richest people on earth did define what developers are:
>
> http://www.ntk.net/ballmer/mirrors.html

I was wondering when someone would mention the "developers, developers,
developers" Ballmer song-and-dance incident: clearly, he isn't chanting
about internal Microsoft project teams.

Paul

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


Re: Queue limitations?

2006-03-16 Thread mateom
I am creating the images by reading from texture memory using
glGetTexImage(). As an experiment, I tried calling glGetTexImage() only
once and letting imagQueue use that same reference over and over, but
the images were all the same.

So, this leads me to believe that the references returned by
glGetTexImage() are to unique buffers, right? ( documentation for
glGetTexImage() doesn't seem to disagree )

Perhaps, as an OpenGL program, something strange is happening with the
references when my producer method goes out of scope. I guess for now I
can be content to just pass immutable types across the thread boundary.

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


Re: Xah's Edu Corner: The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations

2006-03-16 Thread Roedy Green
On 15 Mar 2006 22:20:52 -0800, "Xah Lee" <[EMAIL PROTECTED]> wrote,
quoted or indirectly quoted someone who said :

>e. For example, the in-fix
>notation =E2=80=9C(3+(2*5))>7=E2=80=9D is written as =E2=80=9C3 2 5 * + 7 >=
>=E2=80=9D, where the

Not that Mr. Lee has ever shown much interest in feedback, but you
pretty well have stick to vanilla ASCII to get your notation through
unmangled on newsgroups.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "pow" (power) function

2006-03-16 Thread Mike Ressler
On Wed, 2006-03-15 at 18:46 -0800, Ben Cartwright wrote:

> Anyway, if you want to see the int vs. float issue in action, try this:
> 
>   >>> from timeit import Timer
>   >>> Timer('2**2').timeit()
>   0.12681011582321844
>   >>> Timer('2.0**2.0').timeit()
>   0.6011743438121
>   >>> Timer('2.0**2').timeit()
>   0.36681835556112219
>   >>> Timer('2**2.0').timeit()
>   0.37949818370600497
> 
> As you can see, the int version is much faster than the float version.

I have a counterexample. In the original timeit example, 111**111 was
used. When I run that 

>>> timeit.Timer("pow(111,111)").timeit()
10.968398094177246
>>> timeit.Timer("111**111").timeit()
10.04007887840271
>>> timeit.Timer("111.**111.").timeit()
0.36576294898986816

The pow and ** on integers take 10 seconds, but the float ** takes only
0.36 seconds. (The pow with floats takes ~ 0.7 seconds). Clearly
typecasting to floats is coming in here somewhere. (Python 2.4.1 on
Linux FC4.)

Mike


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


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread Dr.Ruud
[EMAIL PROTECTED] schreef:

> There are many sites
> dedicated to reasonably objective comparisons between languages. Here
> are two examples:
> 
> http://www.smallscript.org/Language%20Comparison%20Chart.asp
> http://www.jvoegele.com/software/langcomp.html

  http://shootout.alioth.debian.org/ 

-- 
Affijn, Ruud

"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread [EMAIL PROTECTED]
The point is to submit elegant code that showcases the features of each
language. And the problem is, just to clarify, given a set WC of
wildcards in any logical combination, and if WC(S^n) is the set all s
in S^n that matches the wildcards, then efficiently generate the
complement S^n\WC(S^n). You are free to restate the problem in any
equivalent way.

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


Re: Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

2006-03-16 Thread Felipe Almeida Lessa
Em Qui, 2006-03-16 às 09:20 +0100, Fredrik Lundh escreveu:
> when you're done with your homework (?), you can compare it with
> Guido's solution:
> 
> http://svn.python.org/view/python/trunk/Demo/scripts/queens.py

Just a curiosity. Running the script as the site lists on my computer:

$ time python2.4 /tmp/queens.py -n 12
Found 14200 solutions.

real0m14.177s
user0m13.700s
sys 0m0.042s

Adding a "import psyco; psyco.full()" clause to the beginning of the
file:

$ time python2.4 /tmp/queens.py -n 12
Found 14200 solutions.

real0m3.250s
user0m3.003s
sys 0m0.012s

At least interesting...

Felipe.

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

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-16 Thread [EMAIL PROTECTED]
Flame war? Absolutely not. My reason is to learn. There are many sites
dedicated to reasonably objective comparisons between languages. Here
are two examples:

http://www.smallscript.org/Language%20Comparison%20Chart.asp
http://www.jvoegele.com/software/langcomp.html

The wildcard exclusion problem is interesting enough to have many
distinct, elegant solutions in as many languages. It would be
interesting to see if they converge to roughly the same solution or if
there are essential differences. And your code is a crash course in
Haskell! Tossing aside the 'flame war' inquiry your code response is my
only goal. I hope many others find the problem and responses as
fascinating as I do.

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


Re: Cheese Shop: some history for the new-comers

2006-03-16 Thread Harald Armin Massa
Tim,

> For most people 'developers' would mean people developing *with* python,
> not developing python.

one of the richest people on earth did define what developers are:

http://www.ntk.net/ballmer/mirrors.html

people developing with something. So, unless we get /F or BDFL to do an
even more astonishing dance proclaiming that people developing Python
are developers, not people developing WITH Python, I guess you are
quite right.

Harald

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


Re: Executing a DOS program from within Python

2006-03-16 Thread Gary Herron
Randy Kreuziger wrote:

>This is probably a  newbie question but I need a kick start to get going.
>
>I need to run a DOS (sdetable) program from within a Python program.  I'll use 
>command line switches so I will not need to interact with the program however 
>it would be nice if I could capture its exit code.
>
>Thanks
>
>
>Randy Kreuziger
>(360) 902-2495  Voice
>(360) 902-2940 Fax
>ArcSDE Administrator
>Wash Dept of Fish and Wildlife
>
>
>  
>
There has been numerous ways to do this in the past (os.system, 
os.spawn, os.exec, and various operations in popen2), with os.system 
being the easiest and perhaps sufficient for your need.

However, if you are running Python 2.4, the I'd suggest the "subprocess" 
module, and in particular its convenience function "call".

Gary Herron

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


Re: email package 4.0a2

2006-03-16 Thread Konrad Hinsen
On Mar 5, 2006, at 22:10, Barry Warsaw wrote:

> I'm happy to announce the release of the email 4.0a2 standalone  
> package.
> This is the latest version of the email package and will be released
> with Python 2.5.  The major changes between this version and email 3.0
> (released with Python 2.4) is:
...

> Note that the old, email version 3 package names are still  
> supported for
> backward compatibility, so you won't have to change existing code.   
> New
> code should use the new names as the old names will go away in Python
> 2.6.  Also note that email.mime.application is /not/ provided as
> email.MIMEApplication.

I am a bit worried by annoucements such as this one, so I would like  
to profit from this opportunity to plead for more stability in Python  
development, even though the concrete case (the email module) is not  
a problem for me.

My interpretation of the above paragraph is that it will be  
impossible to write Python code using the email module (and possibly  
other evolving modules) that works with both Python 2.4 and Python  
2.6. As an author of Python code, I therefore have to choose if I  
want to force my users to update their Python installation (knowing  
that this is impossible or at least a major effort for some of them)  
or if I want to prevent early adopters of new versions from using my  
code. I don't like either option.

 From exchanges with users of my code, I conclude that there are  
significant numbers of users of Python 2.2, 2.3, and 2.4 at the  
moment, plus a small number of users of 2.0 and 2.1. From a few cases  
of Python 2.2 users whose situations I know well, I understand that  
updating is not always an option. For example, there is someone whose  
10 PCs are still running SuSE Linux 8.1 (which includes Python 2.2).  
The PhD student who handles system administration (with minimal  
expertise) adopts the wise approach of never breaking a running  
system. In other words, those machines will remain at SuSE 8.1 and  
Python 2.2 until they will be replaced. This leaves users with the  
only option of installing a newer Python in their home directories -  
not exactly a straightforward task for someone who knows little about  
Python and nothing about system administration.

Given the current situation, I expect that when Python 2.6 is  
released, Python 2.4 will still be in common use.

Personally, I would prefer that all compatibility-breaking changes be  
postponed until Python 3K. I'd rather have worry about compatibility  
once than continously.

Konrad.
--
-
Konrad Hinsen
Laboratoire Léon Brillouin, CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: [EMAIL PROTECTED]
-


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


Re: Large algorithm issue -- 5x5 grid, need to fit 5 queens plus some squares

2006-03-16 Thread [EMAIL PROTECTED]
Thank you very much guys!
Just for clarification it wasn't homework, just extra credit  :)

I can't beleive I didn't realize that I didn't clear the GLOBAL
variable  :D

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


Re: what's going on here?

2006-03-16 Thread John Salerno
Felipe Almeida Lessa wrote:

> # Suppose line is "200412  34.235.233.2"
> # for our comments
> 
> # Creates a list, like ["2004", "12", "34.2", "35.2", "33.2"]
> splitted = line.split() 

Thanks guys! I think what I forgot was that split() returns a list, so 
that's when the 'rows' were being created.
-- 
http://mail.python.org/mailman/listinfo/python-list


Executing a DOS program from within Python

2006-03-16 Thread Randy Kreuziger
This is probably a  newbie question but I need a kick start to get going.

I need to run a DOS (sdetable) program from within a Python program.  I'll use 
command line switches so I will not need to interact with the program however 
it would be nice if I could capture its exit code.

Thanks


Randy Kreuziger
(360) 902-2495  Voice
(360) 902-2940 Fax
ArcSDE Administrator
Wash Dept of Fish and Wildlife


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


Re: what's going on here?

2006-03-16 Thread Felipe Almeida Lessa
Em Qui, 2006-03-16 às 16:31 +, John Salerno escreveu:
> So finally here's my question: If you are using data.append(), doesn't 
> that just put all the numbers into one long list? How are the tuples 
> still being created in this case so that the list comprehensions still 
> work? It seems like there is no longer any 'row' to refer to in data.

Look the line """data.append(map(float, line.split()))"""

In other words:

# Suppose line is "200412  34.235.233.2"
# for our comments

# Creates a list, like ["2004", "12", "34.2", "35.2", "33.2"]
splitted = line.split() 

# Convert all numbers to floats
numbers = map(float, splitted)

# It could also be
# numbers = [float(x) for x in splitted]

# Append the list to the data
# ReportLab accept both lists and tuples, so it doesn't matter
data.append(numbers)


Hope this clarifies your mind,
Felipe.

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

Re: what's going on here?

2006-03-16 Thread Schüle Daniel
[...]

> So finally here's my question: If you are using data.append(), doesn't 
> that just put all the numbers into one long list? 

no, append appends
extend does what you think

How are the tuples
> still being created in this case so that the list comprehensions still 
> work? It seems like there is no longer any 'row' to refer to in data.

why not to fire interpreter to see what happens

 >>> line1 = "1 2 3 4"
 >>> line2 = "5 6 7 8"
 >>> lst = []
 >>> lst.append(map(float, line1.split()))
 >>> lst
[[1.0, 2.0, 3.0, 4.0]]
 >>> lst.append(map(float, line2.split()))
 >>> lst
[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]
 >>>


hth, Daniel

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


Re: Tried Ruby (or, "what Python *really* needs" or "perldoc!")

2006-03-16 Thread john_sips_tea

Jason Earl wrote:
> "msoulier" <[EMAIL PROTECTED]> writes:
>
> >> I have found the Python sidebar VERY helpful:
> >
> > Personally, I can't use local docs on my desktop as they may not be
> > the same version of the docs for the Python distro running on the
> > server that I'm deploying on. I usually go to python.org and use the
> > wayback machine to look at the old docs for the release that I'm on.
>
> Why don't you instead install the info version of the Python
> documentation on your server.  Then you can do "info Python2.3-lib"
> and have at it.  If you are hacking in emacs then this is about as
> slick a documentation system as you could ask for, but even if you use
> some other editor info is a much better documentation tool than man.

You know, I'm pretty used to reading man pages. There's only a
few simple keystrokes I need to remember, and the only time I
ever touch "info" is when a very short man page tells me that the
real docs are in info and I need to look there. At that point, I have
to relearn how to use that info command. Info is complicated. It's
got some concept of nodes being hierarcical, but also they seem
to have some order to them (a la next and previous) as well. No
idea what the connection between those is. Also it's got "cross-
references" as well as menus -- dunno if they're different or not.
Bah. Why not just use html and browse it with lynx/links/links2/elinks?

I can't understand why we need two separate and distinct doc
formats: man and info. My take: write your docs in some markup
that can produce both man output and html. Done and done.
Seems like two good candidates for that are epytext and
reStructuredText ("reST").

> > But, if Python would match Perl for docs available on the
> > command-line, then I'd have it all at my fingertips. I simply don't
> > understand why this is not being done. When I'm coding in C, I use
> > the manpages on the remote host so that I know the docs are correct
> > for my target. Why can't I do that in Python? It's yet another thing
> > that my Perl-using coworkers point out as a Python weakness.
>
> Python does match (and exceed) Perl for docs available on the command
> line.  Once you get used to using the excellent info-based Python
> documentation using man is downright primitive.
>
> Jason

I think that may be wishful thinking. When I use the pydoc command,
I mostly get *very* short API docs with *no* example code or tutorial
notes at all.

Contrast that with perldoc which is categorized and complete docs
for the entire language plus tutorials, faqs, ports info, ... I mean,
have a look over at http://perldoc.perl.org/perl.html -- everything
there is at your fingertips from the terminal! And it's written by
folks
like Larry, Dominus, Randal Schwartz, Tom Christiansen, et al. I've
never come across a FLOSS software project with docs as good as
Perl's.

Now, the one big thing we have going for us is that since Python
is a simpler language, so it needs few docs overall anyway. :)

---John
http://www.simisen.com/jmg/cpd/

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


what's going on here?

2006-03-16 Thread John Salerno
This might be confusing to explain, because it's a question about an 
example in Beginning Python and I'll try to provide all the info I can.

First off, I'm reading a chapter on using the ReportLab modules to 
create a line graph from a set of data. The first implementation of the 
program uses a hard-coded list as the data source, the second 
implementation pulls the data from a URL. In either case, the data is of 
this format:

# year month predicted high low
200412  34.235.233.2
200501  31.534.528.5
(repeated many times)

In the first implementation, the data was a list of tuples, each tuple 
being one row of the data. So grabbing the data was done like this:

pred = [row[2]-40 for row in data]
high = [row[3]-40 for row in data]
etc...

We can safely ignore the '-40', that was just for positioning. So the 
variable for predicted would grab 34.2, 31.5, etc., high would get 35.2, 
etc. Easy enough.

Now, the second implementation does this:

for line in urlopen(URL).readlines():
if not line.isspace() and not line[0] in COMMENT_CHARS:
data.append(map(float, line.split()))

pred = [row[2] for row in data]
high = [row[3] for row in data]
etc.

(URL is the location of the data file online. The if statement just 
checks for blank lines and lines beginning with certain comment 
characters, so they can be ignored.)

So finally here's my question: If you are using data.append(), doesn't 
that just put all the numbers into one long list? How are the tuples 
still being created in this case so that the list comprehensions still 
work? It seems like there is no longer any 'row' to refer to in data.

The only thing I can think of is that each time through the for loop, a 
new item (tuple or list) is being created in the data list, so that each 
row of data really is being separated as its own element in the larger 
list, but that doesn't seem right.

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python2.4.2 + win95, import socket dll error

2006-03-16 Thread John Pote
Dennis,
Thanks for the info. Found winsock2.0 on the MS knowledge base site. 
Downloaded, installed (with the y2k upgrade as recommended) and, amazingly, 
all is working. My simple socket server works no problem as does a test http 
client sending data to my web site. This latter program seems a little 
grainy on updating the wxPython GUI compared to my modern XP box and 
slightly older W2K laptop. But its working!

You might like to know:
I tried searching for winsock 2.2,
on MSK base no hits
on google search many hits but the ones I could make out all refered to 
winsock2.2.exe as a variant of the spybot worm.

Thanks for helping solve the problem,

All the best

John Pote


"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Thu, 16 Mar 2006 01:09:24 GMT, "John Pote"
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>> Hi all,
>> Can someone throw some light on this problem? (is trying to run Python 
>> 2.4.2
>> on an old win95 box a reasonable thing to do?)
>>
> Wasn't Winsock updated between W95 and W98?
>
> You may have the older winsock 1.1, and all the newer stuff is built
> against (and trying to load) winsock 2.2
> -- 
> > == <
> >   [EMAIL PROTECTED]  | Wulfraed  Dennis Lee Bieber  KD6MOG <
> >  [EMAIL PROTECTED] |   Bestiaria Support Staff   <
> > == <
> >   Home Page: <
> >Overflow Page: < 


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


Re: Computing correlations with SciPy

2006-03-16 Thread John Hunter
> "tkpmep" == tkpmep  <[EMAIL PROTECTED]> writes:

tkpmep> I want to compute the correlation between two sequences X
tkpmep> and Y, and tried using SciPy to do so without success.l
tkpmep> Here's what I have, how can I correct it?

 X = [1, 2, 3, 4, 5] Y = [5, 4, 3, 2, 1] import scipy
 scipy.corrcoef(X,Y)
tkpmep> Traceback (most recent call last): File " input>", line 1, in ?  File
tkpmep> "C:\Python24\Lib\site-packages\numpy\lib\function_base.py",
tkpmep> line 671, in corrcoef d = diag(c) File
tkpmep> "C:\Python24\Lib\site-packages\numpy\lib\twodim_base.py",
tkpmep> line 80, in diag raise ValueError, "Input must be 1- or
tkpmep> 2-d."  ValueError: Input must be 1- or 2-d.


Hmm, this may be a bug in scipy.  matplotlib also defines a corrcoef
function, which you may want to use until this problem gets sorted out

In [9]: matplotlib.mlab.corrcoef(X,Y)

In [10]: X = [1, 2, 3, 4, 5]

In [11]: Y = [5, 4, 3, 2, 1]

In [12]: matplotlib.mlab.corrcoef(X,Y)
Out[12]:
array([[ 1., -1.],
   [-1.,  1.]])


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


Re: can't send large messages over SSL socket

2006-03-16 Thread [EMAIL PROTECTED]
Well the first thing to note is that the maximum record length in SSL
is exactly 16384.  SSL/TLS does not preserve message boundaries - it is
up to the application to determine if there are multiple messages in a
single record, or a single message spanning multiple records.  Sounds
like the particular wrapper function is not properly chunking the
message up into multiple records (or just does not support large
messages).

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


Re: Python Documentation Standards

2006-03-16 Thread Duncan Booth
Steven Bethard wrote:

> Colin J. Williams wrote:
>> Doc strings provide us with a great opportunity to illuminate our code.
>> 
>> In the example below, __init__ refers us to the class's documentation,
>> but the class doc doesn't help much.
> 
> It doesn't?
> 
> >>> print list.__doc__
> list() -> new list
> list(sequence) -> new list initialized from sequence's items
> 
> What is it you were hoping to see in constructor documentation?
> 
> STeVe

How about this?:

  >>> print list.__doc__
  list() -> new list
  list(sequence) -> new list initialized from sequence's items
  See http://docs.python.org/lib/built-in-funcs.html#l2h-44

although it would be better if the online docs had a more permanent looking 
anchor.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >