Re: String constants (was "Looping over a list question")

2006-10-03 Thread Tim Chase
> I'd also love to see string constants implemented some day too > (like str.whitespace and str.ascii_letters). You mean like the "string" module provides? :) >>> import string >>> print '\n'.join(["%s -> %s" % (s, repr(eval('string.%s' % s))) for s in dir(string) if isinstance(eval('string.%s

Re: Looping over a list question

2006-10-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > My "print" line is actually a long 40 line block. and? if your editor isn't horribly broken, that shouldn't be much of a problem. (but you may want to refactor the code; if you have a processing block that large, it's probably better to move all or parts of it into a

Re: Looping over a list question

2006-10-03 Thread Leif K-Brooks
Tim Williams wrote: > Maybe > def myfunc(txt): > ... print txt > ... datafiles = ['1.txt','2.txt','3.txt','4.tst'] null = [myfunc(i) for i in datafiles if '.txt' in i] > 1.txt > 2.txt > 3.txt Ew. List comprehensions with side effects are very icky. -- http://mail.python.or

Re: Looping over a list question

2006-10-03 Thread stephen
Fredrik Lundh wrote: [snip] > probably. but unless your editor or keyboard is horribly broken, you > can of course press return at the right place instead: > >for i in datafiles: > if '.txt' in i: > print 'Processing datafile %s' % f > > (for this specific case, "endswi

Re: Looping over a list question

2006-10-03 Thread mdsteele
[EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processing datafile %s' % f > > Has there

Re: Looping over a list question

2006-10-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processing datafile %s' % f > > Has th

Re: Looping over a list question

2006-10-03 Thread Tim Williams
On 3 Oct 2006 10:50:04 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: >

Re: Looping over a list question

2006-10-03 Thread Christoph Haas
On Tuesday 03 October 2006 19:50, [EMAIL PROTECTED] wrote: > I found myself writing: > > for f in [i for i in datafiles if '.txt' in i]: > print 'Processing datafile %s' % f > > but I was wishing that I could have instead written: > > for f in in datafiles if '.txt' in f: > print 'Processin

Looping over a list question

2006-10-03 Thread stephen
I found myself writing: for f in [i for i in datafiles if '.txt' in i]: print 'Processing datafile %s' % f but I was wishing that I could have instead written: for f in in datafiles if '.txt' in f: print 'Processing datafile %s' % f Has there ever been a proposal for this? Just wonderin