Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
know LISP? This is what the basic machinery of LISP looks like in Python: def cons(a,b) return [a,b] should be: return [a].extend(b) def car(structure) return structure[0] def cdr(structure) return structure[1] should be: return structure[1:] B. -- Brendon Towle

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
On 28 Sep 2006, at 8:05 AM, [EMAIL PROTECTED] wrote: From: Bruno Desthuilliers [EMAIL PROTECTED] Subject: Re: Questions on Using Python to Teach Data Structures and Algorithms To: python-list@python.org Brendon Towle wrote: Some of your Lisp translations are subtly off... Seems

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-28 Thread Brendon Towle
.) I think I'd probably prefer: def cons(a,b): res = [a] res.extend(b) return res because cons is supposed to leave its second argument untouched. B. -- Brendon Towle, PhD Cognitive Scientist +1-412-690-2442x127 Carnegie Learning, Inc. The Cognitive Tutor Company ® Helping over

Python API to OS X Address Book?

2006-09-25 Thread Brendon Towle
Essentially, I'm looking for a Python equivalent to the ObjectiveC stuff that can be found at: http://developer.apple.com/documentation/UserExperience/Conceptual/AddressBook/index.html Google got me that far, but was not particularly helpful past that. Anyone have any pointers? B. --

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread Brendon Towle
On 12 Sep 2006, at 6:33 PM, [EMAIL PROTECTED] wrote: Date: 12 Sep 2006 15:23:51 -0700 From: Simon Forman [EMAIL PROTECTED] Subject: Re: Random Drawing Simulation -- performance issue Brendon Towle wrote: I need to simulate scenarios like the following: You have a deck of 3 orange cards, 5

Re: Random Drawing Simulation -- performance issue

2006-09-13 Thread Brendon Towle
, but this just might do the trick. Must ponder. Thanks, everyone, for your helpful suggestions! B. -- Brendon Towle, PhD Cognitive Scientist +1-412-690-2442x127 Carnegie Learning, Inc. The Cognitive Tutor Company ® Helping over 375,000 students in 1000 school districts succeed in math. -- http

Random Drawing Simulation -- performance issue

2006-09-12 Thread Brendon Towle
): index = random.choice(mapping) res[index][0] += 1 return res /code -- Brendon Towle, PhD Cognitive Scientist +1-412-690-2442x127 Carnegie Learning, Inc. The Cognitive Tutor Company ® Helping over 375,000 students in 1000 school districts succeed in math. -- http

Re: sending emails using python

2006-09-07 Thread Brendon Towle
suggestion of talking to the server admin. B. -- Brendon Towle, Ph.D. [EMAIL PROTECTED] +1-412-362-1530 “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” – Brian W

Re: Consistency in Python

2006-08-25 Thread Brendon Towle
ort()    return lst[:n]So, my question is: Someone obviously thought that it was wise and proper to require the longer versions that I write above. Why?B. -- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learning, Inc.The Cognitive Tutor Company ®Helping over 375,000 students

Re: Consistency in Python

2006-08-25 Thread Brendon Towle
Message: 3 Date: Fri, 25 Aug 2006 15:28:46 +0200 From: "Fredrik Lundh" [EMAIL PROTECTED] Subject: Re: Consistency in Python Brendon Towle wrote: So, my question is: Someone obviously thought that it was wise and proper to require the longer versions that I write above. Why? a) mayb

Re: List Splitting

2006-08-21 Thread Brendon Towle
[3*y+x])...    outlist.append(temp)outlist[['a', 'n', 't'], ['b', 'a', 't'], ['c', 'a', 't']] -- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learning, Inc.The Cognitive Tutor Company ®Helping over 375,000 students in 1000 school districts succeed in math. -- http://mail.python.org/mailman/listinfo/python-list

Re: Eval (was Re: Question about using python as a scripting language)

2006-08-10 Thread Brendon Towle
great piece of code to parse a subset of pythonsafely:http://groups.google.ca/group/comp.lang.python/browse_frm/thread/8e427c5e6da35c/a34397ba74892b4eThis, as it turns out, was the most helpful pointer of them all -- thanks!B. -- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learnin

Re: Eval (was Re: Question about the use of python as a scripting language)

2006-08-10 Thread Brendon Towle
r table_body = 'END_MARKER = '];'    def extractStockData(data):    pos1 = data.find(START_MARKER)    pos2 = data.find(END_MARKER, pos1)    parenPos = data.find('(')    if parenPos = 0:        raise "Data format changed -- found a paren"    else:        return eval(data[pos1+len(START

Re: Eval (was Re: Question about the use of python as a scripting language)

2006-08-10 Thread Brendon Towle
long before I call eval().2. Include it in the page I downloaded -- in this case, the function calls will be part of the string, and the data.pos('(') call will find them.Am I missing a third option? B.-- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learning, Inc.The Cognitive

Eval (was Re: Question about using python as a scripting language)

2006-08-09 Thread Brendon Towle
d the code actually works.)My question is: what's the safe way to do this?B. -- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learning, Inc.The Cognitive Tutor Company ®Helping over 375,000 students in 1000 school districts succeed in math. -- http://mail.python.org/mailman/listinfo/python-list

Re: Eval (was Re: Question about using python as a scripting language)

2006-08-09 Thread Brendon Towle
e the re.* trick mentioned by another poster. But, doesn't it offend anyone else that the only clean way to access functionality that's already in Python is to write long complicated Python code? Python already knows how to extract a list object from a string; why should I have to rewrite that?B.On Wed, A

Re: Eval (was Re: Question about using python as a scripting language)

2006-08-09 Thread Brendon Towle
to exploit that identical-ness; apparently, all the clean ways are unsafe, and all the safe ways are unclean.B. -- Brendon Towle, PhDCognitive Scientist+1-412-690-2442x127Carnegie Learning, Inc.The Cognitive Tutor Company ®Helping over 375,000 students in 1000 school districts succeed in math