Re: write a loopin one line; process file paths

2005-10-24 Thread Graham Fawcett
Xah Lee wrote: > Dear Peter Hansen, > My messages speak themselfs. You and your cohorts's stamping of it does > not change its nature. And if this is done with repetitiousness, it > gives away your nature. Taunt not the cohorts of Peter Hansen! Graham -- http://mail.python.org/mailman/listinfo/

Re: write a loopin one line; process file paths

2005-10-24 Thread John Thingstad
On Wed, 19 Oct 2005 11:48:01 +0200, Xah Lee <[EMAIL PROTECTED]> wrote: > Thanks a lot for various notes. Bonono? > > I will have to look at the itertools module. Just went to the doc > http://www.python.org/doc/2.4.1/lib/module-itertools.html > looks interesting. > >> But I believe Python is desig

Re: write a loopin one line; process file paths

2005-10-19 Thread Jeremy Jones
Xah Lee wrote: >Peter Hansen wrote: > > >>Xah Lee wrote: >> >> >>>If you think i have a point, ... >>> >>> >>You have neither that, nor a clue. >> >> > >Dear Peter Hansen, > >My messages speak themselfs. You and your cohorts's stamping of it does >not change its nature. And if this

Re: write a loopin one line; process file paths

2005-10-19 Thread [EMAIL PROTECTED]
Xah Lee wrote: > This i'm not sure. Of the past couple of years i increasingly developed > a theory (probably well-known among proper experts), that the > difficulty of human feats of various forms, are primarily a perception > and familiarity thing. This may be getting off topic, but i wrote an >

Re: write a loopin one line; process file paths

2005-10-19 Thread Xah Lee
Thanks a lot for various notes. Bonono? I will have to look at the itertools module. Just went to the doc http://www.python.org/doc/2.4.1/lib/module-itertools.html looks interesting. > But I believe Python is designed for easy to code and read and maintain > in mind. > One has to admit that with

Re: write a loopin one line; process file paths

2005-10-19 Thread [EMAIL PROTECTED]
Xah Lee wrote: > besides syntactical issues, another thing with doing functional > programing in imperative languages is that they become very inefficent. > Functional languages are optimized by various means of functional > programings styles. Doing them in imperative languages usually comes > wi

Re: write a loopin one line; process file paths

2005-10-19 Thread Xah Lee
[EMAIL PROTECTED] wrote: > it will be added in 2.5 I beleve. At the moment, you can: > > predicate and or Ah, i see. Here's the full code again: # -*- coding: utf-8 -*- # python import re, os.path imgPaths=[u'/Users/t/t4/oh/DSCN2059m-s.jpg', u'/Users/t/t4/oh/DSCN2062m-s.jpg', u'/Users/t/t4/o

Re: write a loopin one line; process file paths

2005-10-18 Thread [EMAIL PROTECTED]
it will be added in 2.5 I beleve. At the moment, you can: predicate and or like : >>> os.paths.exists(something) and "print it is there" or "file not found" I am practicing FP in python and it is in general doable with the help of itertools and add the needed functions as needed, like scanl/sc

Re: write a loopin one line; process file paths

2005-10-18 Thread Xah Lee
Thanks. Here's how the inner loop should be: imgPaths2=map(lambda x: (x, re.sub( r"^(.+?)-s(\.[^.]+)$",r"\1\2", x)), imgPaths) though, now i just need something like map( lambda x: os.path.exists(s)? x[1]:x[0],impPaths2) but Pyhton doesn't support the test ? trueResult : falseResult construct.

Re: write a loopin one line; process file paths

2005-10-18 Thread [EMAIL PROTECTED]
what do you mean by one line ? Using map/filter, I believe it is possible. Somthing like: map(lambda (s,f): os.path.exists(f) and f or s, map(lambda x: (x, re.replace(x, "-s","")), imgPaths) My regex is a bit rusty but I hope you got the idea of what I am trying to do. If there is a way to m

Re: write a loopin one line; process file paths

2005-10-18 Thread Xah Lee
Peter Hansen wrote: > Xah Lee wrote: > > If you think i have a point, ... > > You have neither that, nor a clue. Dear Peter Hansen, My messages speak themselfs. You and your cohorts's stamping of it does not change its nature. And if this is done with repetitiousness, it gives away your nature.

Re: write a loopin one line; process file paths

2005-10-18 Thread Peter Hansen
Xah Lee wrote: > If you think i have a point, ... You have neither that, nor a clue. (Newsgroups line trimmed to reduce the effects of cross-posting trolls.) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: write a loopin one line; process file paths

2005-10-18 Thread Xah Lee
Xah Lee wrote: > is there a way to condense the following loop into one line? > > # -*- coding: utf-8 -*- > # python > > import re, os.path > > imgPaths=[u'/Users/t/web/Periodic_dosage_dir/lanci/t4/oh/DSCN2059m-s.jpg', > u'/Users/t/web/Periodic_dosage_dir/lanci/t4/oh/DSCN2062m-s.jpg', > u'/Users/t

Re: write a loopin one line; process file paths

2005-10-18 Thread Jp Calderone
On 18 Oct 2005 14:56:32 -0700, Xah Lee <[EMAIL PROTECTED]> wrote: >is there a way to condense the following loop into one line? There is. exec('696d706f72742072652c206f732e706174680a0a696d6750617468733d5b75272f55736572732f742f7765622f506572696f6469635f646f736167655f6469722f6c616e63692f74342f6f682

write a loopin one line; process file paths

2005-10-18 Thread Xah Lee
is there a way to condense the following loop into one line? # -*- coding: utf-8 -*- # python import re, os.path imgPaths=[u'/Users/t/web/Periodic_dosage_dir/lanci/t4/oh/DSCN2059m-s.jpg', u'/Users/t/web/Periodic_dosage_dir/lanci/t4/oh/DSCN2062m-s.jpg', u'/Users/t/web/Periodic_dosage_dir/lanci/t4