this is from memory, and 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
ke 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 rewr
t object; it's a string of bytes that happens to be syntactically identical to the definition of a list in python code. I was hoping for a clean and safe way to exploit that identical-ness; apparently, all the clean ways are unsafe, and all the safe ways are unclean.B. -- Brendon Towle,
posted a 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-2442x127Carn
Date: Thu, 10 Aug 2006 08:51:12 -0400From: Brendon Towle <[EMAIL PROTECTED]>Subject: Re: Eval (was Re: Question about using python as a scripting language) Date: 9 Aug 2006 14:12:01 -0700From: "Simon Forman" <[EMAIL PROTECTED]>Subject: Re: Eval (was Re: Question about using
ld people expect this code to be safe:START_MARKER = 'var 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 cha
rt the class -- in this case, I'm screwed 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 Scient
... temp.append(t[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
lst.append(INVARIANT) lst.sort() 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
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
lib.SMTP(host)
if auth:
server.login('username', 'password')
outMessage = 'From: %s\rTo: %s\rSubject: %s\r%s' %
(FROM_HEADER, TO_HEADER, subject, body)
server.sendmail(fromAddr, toAddr, outMessage)
If this doesn't wo
"""
res = [[0, item[1]] for item in population]
mapping = []
for i in xrange(len(population)):
mapping.extend([i]*population[i][0])
for i in xrange(count):
index = random.choice(mapping)
res[index][0] += 1
return res
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 th
vals is a sequence of probabilities that should sum to 1
> (however, the
> last element is always assumed to account for the remaining
> probability
> as long as sum(pvals[:-1]) <= 1).
Here, I'm torn. I do want the code to be accessible to non-stats
people
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.
--
http:
return structure[1]
should be:
return structure[1:]
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
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 Li
s of the "Why don't destructive sequence operations
return the sequence?" thread.)
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
Cog
18 matches
Mail list logo