[Python-3000] end scope of iteration variables after loop

2008-04-16 Thread Nicholas T
hello all, A few times in practice I have been tripped up by how Python keeps variables in scope after a loop--and it wasn't immediately obvious what the problem was. I think it is one of the ugliest and non-intuitive features, and hope some others agree that it should be changed in py3k. >>>

Re: [Python-3000] end scope of iteration variables after loop

2008-04-16 Thread Nicholas T
about the current parser's implementation, but it doesn't seem like scoping necessitates slow parsing -- considering it's done in other languages, and python functions have reasonable scope. >>> def do_nothing(i): i = 3 ... >>> do_nothing(1) >>> i 10 Nichola

Re: [Python-3000] end scope of iteration variables after loop

2008-04-18 Thread Nicholas T
Amaury - I think it's generally cleaner code to write for myObject in someList: if myObject.fits(): process(myObject) break than for myObject in someList: if myObject.fits(): break process(myObject) I see from csv.py how it could simplify thing

[Python-3000] what do I use in place of reduce?

2008-04-23 Thread Nicholas T
Hi all, It's obvious how to use LC's to replace map and filter, but what about reduce? It is one of my favorite functions. >>> time=1901248 >>> reduce(lambda a, b: a[:-1] + [a[-1]%b, math.floor(a[-1]/b)], [[time], 60, 60, 24]) [28, 7.0, 0.0, 22.0] # secs, mins, hrs, days Nicholas -- http://

Re: [Python-3000] what do I use in place of reduce?

2008-04-23 Thread Nicholas T
On Wed, Apr 23, 2008 at 9:08 PM, Alex Martelli <[EMAIL PROTECTED]> wrote: > On Wed, Apr 23, 2008 at 6:47 PM, Guido van Rossum <[EMAIL PROTECTED]> > wrote: > > On Wed, Apr 23, 2008 at 1:56 PM, Nicholas T <[EMAIL PROTECTED]> wrote: > > > > >It's

Re: [Python-3000] what do I use in place of reduce?

2008-04-24 Thread Nicholas T
On Thu, Apr 24, 2008 at 11:23 AM, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > This is getting off-topic, so you don't need to answer; I still ask: > Why??? yes I know, apologies for not mailing the right list. I'll try to do so next time. Dividing the previous result seems more logical: minute

Re: [Python-3000] what do I use in place of reduce?

2008-04-24 Thread Nicholas T
On Wed, Apr 23, 2008 at 10:35 PM, Alex Martelli <[EMAIL PROTECTED]> wrote: > Is 119 vs 117 characters "a LOT of verbosity"...?! OK, then what about...: the reduce is actually 69 *and only one line* if you don't need it in a function. You can't put the dhms2 in a function unless you want to leak