New Science Discovery: Perl Idiots Remain Idiots After A Decade!
A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
on “Operators”. Quote:
«The associativity of an operator governs whether it evaluates from
left to right or right to left. Addition is left associative, such
that
y bad written. Becha ass!
Xah
On Feb 29, 4:08 am, Kiuhnm wrote:
> On 2/29/2012 9:09, Xah Lee wrote:
>
>
> > New Science Discovery: Perl Idiots Remain Idiots After A Decade!
>
> > A excerpt from the new book 〈Modern Perl〉, just published, chapter 4
> > on “Operator
fun example.
in-place algorithm for reversing a list in Perl, Python, Lisp
http://xahlee.org/comp/in-place_algorithm.html
plain text follows
What's “In-place Algorithm”?
Xah Lee, 2012-02-29
This page tells you what's “In-place algorithm”, usi
On Feb 29, 9:01 pm, Steven D'Aprano wrote:
> You don't need a temporary variable to swap two values in
> Python. A better way to reverse a list using more Pythonic idioms is:
>
> for i in range(len(list_a)//2):
> list_a[i], list_a[-i-1] = list_a[-i-1], list_a[i]
forgive me sir, but i haven't
On Mar 1, 7:04 am, Kaz Kylheku wrote:
lisp:
(floor (/ x y)) --[rewrite]--> (floor x y)
Thanks for this interesting point.
I don't think it's a good lang design, more of a lang quirk.
similarly, in Python 2.x,
x/y
will work when both x and y are integers. Also,
x//y
works too, but that // is j
Xah Lee wrote:
«… One easy way to measure it is whether a programer can read and
understand a program without having to delve into its idiosyncrasies.
…»
Chris Angelico wrote:
«Neither the behavior of ints nor the behavior of IEEE floating point
is a "quirk" or an "idiosyncracy
n when 2 operators are adjacent e.g. 「3 △ 6 ▲ 5 」?
do you happen to know some site that shows the relevant page i can
have a look?
thanks.
Xah
On Mar 1, 3:00 am, Kiuhnm wrote:
> On 3/1/2012 1:02, Xah Lee wrote:
>
> > i missed a point in my original post. That is, when the same
some additional info i thought is relevant.
are int, float, long, double, side-effects of computer engineering?
Xah Lee wrote:
«… One easy way to measure it is whether a programer can read and
understand a program without having to delve into its idiosyncrasies.
…»
Chris Angelico wrote
On Mar 5, 9:26 pm, Tim Roberts wrote:
> Xah Lee wrote:
>
> >some additional info i thought is relevant.
>
> >are int, float, long, double, side-effects of computer engineering?
>
> Of course they are. Such concepts violate the purity of a computer
> language
here's a interesting problem that we are discussing at comp.lang.lisp.
〈Parallel Programing Problem: asciify-string〉
http://xahlee.org/comp/parallel_programing_exercise_asciify-string.html
here's the plain text. Code example is emacs lisp, but the problem is
general.
for a bit python relevancy…
〈Perl Documentation: The Key to Perl〉
http://xahlee.org/perl-python/key_to_perl.html
plain text follows
-
So, i wanted to know what the option perl -C does. So, here's perldoc
perlrun. Excerpt:
-C [*number/list*]
The -C flag controls some
the refreshen of the blood, from Xah's Entertainment Enterprise, i
bring you:
ãIs Programing Art or Scienceã
http://xahlee.org/UnixResource_dir/writ/art_or_science.html
penned in the year of our lord two thousand and two, plain text
version follows.
Is Progra
Dearly beloved lisperati,
I present you, Ron Garret (aka Erann Gat — aka Naggum hater and enemy
of Kenny Tilton), at Google Tech Talk
〈The Remote Agent Experiment: Debugging Code from 60 Million Miles
Away〉
Google Tech Talk, (2012-02-14) Presented by Ron Garret. @
http://www.youtube.com/watch?v=_
On Apr 3, 8:22 am, Rainer Weikusat wrote:
> Xah Lee writes:
>
> [...]
>
> > For example, “Is mathematics science or art?”, is the same type of
> > question that has been broached by dabblers now and then.
>
http://en.wikipedia.org/wiki/Liberal_arts
this is the best
format follows, as a amenity for tech
geekers.
---
World Multiconference on Systemics, Cybernetics and Informatics ???
Xah Lee, 2010-04-04
Starting in 2004, i regularly receive email asking me to participate a
conference, called “World Multiconference
hi guys,
sorry am feeling a bit prolifit lately.
today's show, is: 〈Fuck Python〉
http://xahlee.org/comp/fuck_python.html
Fuck Python
By Xah Lee, 2012-04-08
fuck Python.
just fucking spend 2 hours and still going.
here's the short story.
so
On Apr 8, 4:34 am, Steven D'Aprano wrote:
> On Sun, 08 Apr 2012 04:11:20 -0700, Xah Lee wrote:
>
> [...]
>
> I have read Xah Lee's post so that you don't have to.
>
> Shorter Xah Lee:
>
> "I don't know Python very well, and rather than adm
Xah Lee wrote:
« http://xahlee.org/comp/fuck_python.html »
David Canzi wrote
«When Microsoft created MS-DOS, they decided to use '\' as the
separator in file names. Â This was at a time when several previously
existing interactive operating systems were using '/' as the
〈Emacs Lisp vs Perl: Validate Local File Links〉
http://xahlee.org/emacs/elisp_vs_perl_validate_links.html
a comparison of 2 scripts.
lots code, so i won't paste plain text version here.
i have some comments at the bottom. Excerpt:
--
«One thing interesting is to compare the app
Functional programing is getting the presses in mainstream. I ran
across this dialogue where a imperative coder was trying to get into
functional programing:
A: What are the design patterns that help structure functional
systems?
B: Design patterns? Hey everyone, look at the muggle try to get
John Carmack glorifying functional programing in 3k words
http://www.altdevblogaday.com/2012/04/26/functional-programming-in-c/
where was he ten years ago?
O, and btw, i heard that Common Lispers don't do functional
programing, is that right?
Fuck Common Lispers. Yeah, fuck them. One bunch of F
Learn Technical Writing from Unix Man in 10 Days
Quote from man apt-get:
remove
remove is identical to install except that packages are
removed
instead of installed.
Translation:
kicking
kicking is identical to kissing except that receiver is kicked
inste
On Apr 29, 7:43 pm, Jason Earl wrote:
> On Sat, Apr 28 2012, Steven D'Aprano wrote:
> > On Sat, 28 Apr 2012 14:55:42 -0700, Xah Lee wrote:
>
> >> Learn Technical Writing from Unix Man in 10 Days
>
> >> Quote from man apt-get:
>
> >> remove
Dear lisp comrades, it's Friday!
Dear Xah, your writing is:
• Full of bad grammar. River of Hiccups.
• Stilted. Chocked under useless structure and logic.
• WRONG — Filled with uncouth advices.
• Needlessly insulting. You have problems.
• Simply stinks. Worthless.
• M
(a lil weekend distraction from comp lang!)
in recent years, there came this Colemak layout. The guy who created
it, Colemak, has a site, and aggressively market his layout. It's in
linuxes distro by default, and has become somewhat popular.
I remember first discovering it perhaps in 2007. Me, be
On Jun 13, 6:45 pm, Gregory Ewing wrote:
> Chris Angelico wrote:
> > And did any of the studies take into account the fact that a lot of
> > computer users - in all but the purest data entry tasks - will use a
> > mouse as well as a keyboard?
>
> What I think's really stupid is designing keyboard
On Jun 13, 6:19 am, Steven D'Aprano 〔steve
+comp.lang.pyt...@pearwood.info〕 wrote:
│ I don't know if there are any studies that indicate how much of a
│ programmer's work is actual mechanical typing but I'd be surprised
if it
│ were as much as 20% of the work day. The rest of the time being
thinki
Ba Wha 13, 7:23 nz, Ehfgbz Zbql 〔ehfgbzcz...@tznvy.pbz〕 jebgr:
│ Qibenx -- yvxr djregl naq nal bgure xrlobneq ynlbhg -- nffhzrf gur
│ pbzchgre vf n glcrjevgre.
│ Guvf zrnaf va rssrpg ng yrnfg gjb pbafgenvagf, arprffnel sbe gur
│ glcrjevgre ohg abg sbe gur pbzchgre:
│
│ n. Gur glcvfg pna glcr bayl
for some reason, was unable to post the previous message. (but can
post others) So, the message is rot13'd and it works. Not sure what's
up with Google groups. (this happened a few years back once.
Apparantly, the message content might have something to do with it
because rot13 clearly works. Yet,
On Jun 14, 7:50 am, Dotan Cohen wrote:
> On Mon, Jun 13, 2011 at 10:21, Elena wrote:
> > On 13 Giu, 06:30, Tim Roberts wrote:
> >> Studies have shown that even a
> >> strictly alphabetical layout works perfectly well, once the typist is
> >> acclimated.
>
> > Once the user is acclimated to move
On Jun 15, 5:43 am, rusi wrote:
> On Jun 15, 5:32 pm, Dotan Cohen wrote:
>
> > Thanks. From testing small movements with my fingers I see that the
> > fourth finger is in fact a bit weaker than the last finger, but more
> > importantly, it is much less dexterous. Good to know!
>
> Most of the pia
On Jun 17, 2:26 pm, Dotan Cohen wrote:
> On Fri, Jun 17, 2011 at 20:43, Xah Lee wrote:
> > u r aware that there are already tens of layouts, each created by
> > programer, thinking that they can create the best layout?
>
> Yes. Mine is better :)
> Had Stallman not heard
On Jun 18, 4:06 am, Dotan Cohen wrote:
> On Sat, Jun 18, 2011 at 01:09, Xah Lee wrote:
> > thanks. didn't know about Ducky keyboard. Looks good. Also nice to
> > hear your experience about Truly Ergonomic keyboard.
>
> I like it, see my first-hour review
> here:htt
this will be of interest to those bleeding-edge pythoners.
“what… is the airspeed velocity of an unladen swallow?”
xahlee.org/funny/unladen_swallow.html
Xah
--
http://mail.python.org/mailman/listinfo/python-list
llows.
--
Emacs Lisp: Processing HTML: Transform Tags to HTML5 “figure” and
“figcaption” Tags
Xah Lee, 2011-07-03
Another triumph of using elisp for text processing over perl/python.
The Problem
--
Summary
I want batch tran
On Jul 4, 12:13 pm, "S.Mandl" wrote:
> Nice. I guess that XSLT would be another (the official) approach for
> such a task.
> Is there an XSLT-engine for Emacs?
>
> -- Stefan
haven't used XSLT, and don't know if there's one in emacs...
it'd be nice if someone actually give a example...
Xah
--
On Jul 5, 12:17 pm, Ian Kelly wrote:
> On Mon, Jul 4, 2011 at 12:36 AM, Xah Lee wrote:
> > So, a solution by regex is out.
>
> Actually, none of the complications you listed appear to exclude
> regexes. Here's a possible (untested) solution:
>
>
>
On Jul 5, 12:17 pm, Ian Kelly wrote:
> On Mon, Jul 4, 2011 at 12:36 AM, Xah Lee wrote:
> > So, a solution by regex is out.
>
> Actually, none of the complications you listed appear to exclude
> regexes. Here's a possible (untested) solution:
>
>
>
2011-07-11
On Jul 11, 6:51 am, jvt wrote:
> I might as well toss my two cents in here. Xah, I don't believe that
> the functional programming idiom demands that we construct our entire
> program out of compositions and other combinators without ever naming
> anything. That is much more the pro
maybe this will be of interest.
〈What Programing Language Are the Largest Website Written In?〉
http://xahlee.org/comp/website_lang_popularity.html
-
i don't remember how, but today i suddenly got reminded that Facebook
is written in PHP. So, on the spur of the mo
2011-07-16
folks, this one will be interesting one.
the problem is to write a script that can check a dir of text files
(and all subdirs) and reports if a file has any mismatched matching
brackets.
• The files will be utf-8 encoded (unix style line ending).
• If a file has mismatched matching-p
On Jul 17, 12:47 am, Xah Lee wrote:
> 2011-07-16
>
> folks, this one will be interesting one.
>
> the problem is to write a script that can check a dir of text files
> (and all subdirs) and reports if a file has any mismatched matching
> brackets.
> …
Ok, here's
On Jul 18, 7:07 pm, Billy Mays wrote:
> On 7/18/2011 7:56 PM, Steven D'Aprano wrote:
>
>
>
>
>
>
>
>
>
> > Billy Mays wrote:
>
> >> On 07/17/2011 03:47 AM, Xah Lee wrote:
> >>> 2011-07-16
>
> >> I gave it a shot. It doe
On Sunday, July 17, 2011 2:48:42 AM UTC-7, Raymond Hettinger wrote:
> On Jul 17, 12:47 am, Xah Lee wrote:
> > i hope you'll participate. Just post solution here. Thanks.
>
> http://pastebin.com/7hU20NNL
just installed py3.
there seems to be a bug.
in this file
http://xahle
On Jul 18, 10:12 am, Billy Mays
<81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote:
> On 07/17/2011 03:47 AM,XahLee wrote:
>
> > 2011-07-16
>
> I gave it a shot. It doesn't do any of the Unicode delims, because
> let's face it, Unicode is for goobers.
>
> import sys, os
>
> pair
On Jul 18, 2:59 pm, Thomas 'PointedEars' Lahn
wrote:
> Ian Kelly wrote:
> > Billy Mays wrote:
> >> I gave it a shot. It doesn't do any of the Unicode delims, because let's
> >> face it, Unicode is for goobers.
>
> > Uh, okay...
>
> > Your script also misses the requirement of outputting the inde
On Jul 17, 8:31 am, Thomas Jollans wrote:
> On Jul 17, 9:47 am,XahLee wrote:
>
>
>
>
>
>
>
>
>
> > 2011-07-16
>
> > folks, this one will be interesting one.
>
> > the problem is to write a script that can check a dir of text files
> > (and all subdirs) and reports if a file has any mismatched mat
On Jul 19, 10:33 am, Billy Mays
<81282ed9a88799d21e77957df2d84bd6514d9...@myhashismyemail.com> wrote:
> On 07/19/2011 01:14 PM,XahLee wrote:
>
> > I added other unicode brackets to your list of brackets, but it seems
> > your code still fail to catch a file that has mismatched curly quotes.
> > (e.
pt to Validate Matching Brackets
Xah Lee, 2011-07-19
This page shows you how to write a elisp script that checks thousands
of files for mismatched brackets.
The Problem
Summary
I h
On Jul 19, 11:14 am, Thomas Jollans wrote:
> I thought I'd have some fun with multi-processing:
Nice joke. ☺
> Here's a sane version:
>
> https://gist.github.com/1087682/2240a0834463d490c29ed0f794ad15128849ff8e
hi thomas,
i still cant get your code to work. I have a dir named xxdir with a
sing
On Jul 19, 11:07 am, Thomas Jollans wrote:
> On 19/07/11 18:54, Xah Lee wrote:
>
>
>
>
>
>
>
>
>
> > On Sunday, July 17, 2011 2:48:42 AM UTC-7, Raymond Hettinger wrote:
> >> On Jul 17, 12:47 am, Xah Lee wrote:
> >>> i hope you
2011-07-21
On Jul 18, 12:09 am, Rouslan Korneychuk wrote:
> I don't know why, but I just had to try it (even though I don't usually
> use Perl and had to look up a lot of stuff). I came up with this:
>
> /(?|
> (\()(?&matched)([\}\]”›»】〉》」』]|$) |
> (\{)(?&matched)([\)\]”›»】〉》」』]|$) |
>
suggestion of ideas.
i haven't done extensive testing on my own code neither.
I'll revisit maybe in a few days.
Feel free to grab my report and make it nice. If you would like to fix
your code, feel free to email.
Xah
On Jul 21, 7:26 am, Ian Kelly wrote:
> On Thu, Jul 21
On Jul 21, 9:43 am, pyt...@bdurham.com wrote:
> Xah,
>
> 1. Is the following string considered legal?
>
> [ { ( ] ) }
>
> Note: Each type of brace opens and closes in the proper sequence. But
> inter-brace opening and closing does not make sense.
nu!
> Or must a closing brace always balance out
On Jul 31, 11:38 am, gavino wrote:
> On Jul 13, 1:04 pm, ccc31807 wrote:
>
>
>
>
>
>
>
>
>
> > On Jul 12, 7:54 am, Xah Lee wrote:
>
> > > maybe this will be of interest.
>
> > > 〈What Programing Language Are t
On Feb 28, 7:30 pm, rusi wrote:
> On Feb 28, 11:39 pm, Dotan Cohen wrote:
>
> > You miss the canonical bad character reuse case: = vs ==.
>
> > Had there been more meta keys, it might be nice to have a symbol for
> > each key on the keyboard. I personally have experimented with putting
> > the sy
On Mar 1, 3:40 pm, Chris Jones wrote:
> At first it looks like something MS (Morgan Stanley..) dumped into the
> OSS lap fifteen years ago and nobody ever used it or maintained it.. so
> it takes a bit of digging to make it.. sort of work in current GNU/linux
> distributions.. especially since it
might be of interest.
〈English Idiom in Unix: Directory Recursively〉
http://xahlee.org/comp/idiom_directory_recursively.html
--
English Idiom in Unix: Directory Recursively
Xah Lee, 2011-05-17
Today, let's discuss something in the category of lingu
Xah wrote:
«In the emacs case: “Recursive delete of xx? (y or n) ”, what could it
possibly mean by the word “recursive” there? Like, it might delete the
directory but not delete all files in it?
»
Jonathan de Boyne Pollard wrote:
> It might *try* to delete the directory but not any of its contents
this is important but i think most lispers and functional programers
still don't know it.
Functional Programing: stop using recursion, cons. Use map & vectors.
〈Guy Steele on Parallel Programing〉
http://xahlee.org/comp/Guy_Steele_parallel_computing.html
btw, lists (as cons, car, cdr) in the lis
On May 22, 3:46 pm, Chris Angelico wrote:
> On Mon, May 23, 2011 at 6:22 AM, Xah Lee wrote:
> > Xah wrote:
> > «In the emacs case: “Recursive delete of xx? (y or n) ”, what could it
> > possibly mean by the word “recursive” there? Like, it might delete the
> > directo
On May 22, 4:32 pm, Chris Angelico wrote:
> On Mon, May 23, 2011 at 9:17 AM, Xah Lee wrote:
> > the context is this: In emacs directory manager (aka dired), when you
> > call dired-do-delete on a directory, emacs prompts, this way:
> > “Recursive delete of xx? (y or n)”
>
On May 23, 9:28 pm, Chris Angelico wrote:
> On Tue, May 24, 2011 at 2:20 PM, Xah Lee wrote:
> > why don't you file a bug report? In GNU Emacs 23.2, it's under the
> > Help menu. I suppose it's the same in other emacs distro.
>
> Because I do not consider its b
On May 24, 3:06 pm, Rikishi42 wrote:
> On 2011-05-24, Steven D'Aprano wrote:
>
> >>> I think that is a patronizing remark that under-estimates the
> >>> intelligence of lay people and over-estimates the difficulty of
> >>> understanding recursion.
>
> >> Why would you presume this to be related t
On May 25, 12:26 am, Thorsten Kampe wrote:
> * Rikishi42 (Wed, 25 May 2011 00:06:06 +0200)
>
>
>
>
>
>
>
>
>
>
>
> > On 2011-05-24, Steven D'Aprano wrote:
> > >>> I think that is a patronizing remark that under-estimates the
> > >>> intelligence of lay people and over-estimates the difficulty of
On May 26, 4:20 am, Thorsten Kampe wrote:
> Did your mom tell you to "recursively clean up your room"?.
that had me L O L!
i think i'll quote in my unix hating blogs sometimes, if you don't
mind. ☺
Xah
--
http://mail.python.org/mailman/listinfo/python-list
A Moronicity of Guido van Rossum
Xah Lee, 200509
On Guido van Rossum's website:
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
dated 20050826, he muses with the idea that he would like to remove
lambda, reduce(), filter() and map() constructs in a future version
Python 3000.
addendum:
reduce() in fact embodies a form of iteration/recursion on lists, very
suitable in a functional language environment. If Python's lambda and
other functional facilities are more powerful, reduce() would be a good
addition. For instance, in functional programing, it is a paradigm to
nest
the programers in the industry, including bigwigs such as Guido or that
Larry Wall fuckhead, really don't know shit about computer languages.
Sometimes i get pissed by Stephen Wolfram's megalomaniac cries, but in
many ways, i think his statements about the fucking moronicities of the
academicians a
would anyone like to translate the following perl script to Python or
Scheme (scsh)?
the file takes a inpath, and report all html files in it above certain
size. (counting inline images)
also print a sorted report of html files and their size.
(a copy of the script is here:
http://xahlee.org/_scr
Xah Lee wrote: « would anyone like to translate the following perl
script to Python or Scheme (scsh)?»
Here's the Python version.
# -*- coding: utf-8 -*-
# Python
# Wed Oct 5 15:50:31 PDT 2005
# given a dir, report all html file's size. (counting inline images)
# XahLee.org
there is a MacPerl program posted in 1998 that uses Mac's speech synth
to sing Daisy Bell.
See:
http://bumppo.net/lists/macperl/1998/11/msg00412.html
can anyone modify it so it runs out of the box on today's OS X?
PS i'm posting this also in python and lisp group, i hope it'd be some
general int
Dear Michael Goettsche,
why don't you lead the pack to be on-topic for a change, huh?
Xah
Michael Goettsche wrote:
> On Saturday 08 October 2005 22:10, Xah Lee wrote:
> > there is a MacPerl program posted in 1998 that uses Mac's speech synth
> > to sing Daisy Be
i'm trying to lookup on the detail of language Python's “lambda”
function feature. I've seen it before, but today i need to read about
it again since i'm writing. I quickly went to the index page:
http://python.org/doc/2.4.1/lib/genindex.html
but all i got is a LambdaType.
i'm thinking, maybe buil
Sort a List
Xah Lee, 200510
In this page, we show how to sort a list in Python & Perl and also
discuss some math of sort.
To sort a list in Python, use the “sort” method. For example:
li=[1,9,2,3];
li.sort();
print li;
Note that sort is a method, and the list is changed in place.
Sup
Python Doc Problem Example: sort()
Xah Lee, 200503
Exhibit: Incompletion & Imprecision
Python doc “3.6.4 Mutable Sequence Types” at
http://python.org/doc/2.4/lib/typesseq-mutable.html
in which contains the documentation of the “sort” method of a list.
Quote:
«
Operation Result N
Addendum, 200510
Here's further example of Python's extreme low quality of
documentation. In particular, what follows focuses on the bad writing
skill aspect, and comments on some language design and quality issues
of Python.
>From the Official Python documentation of the sort() method, at:
http:
Sorting in Perl
In Perl, to sort a list, do like this:
@li=(1,9,2,3);
@li2 = sort {$a <=> $b} @li;
print join(' ', @li2);
In Perl, sort is a function, not some Object Oriented thing. It returns
the sorted result as another list. This is very simple and nice.
It works like this: sort takes the
Lasse Vågsæther Karlsen wrote:
> Like the sorted function in Python ?
>
> li2 = sorted(li)
>
> you can also specify a key and a cmp function if you need to.
Thanks. I didn't know there's also a sort function in Python (2.4),
besides the method. (i've mentioned your name as acknowledgement at my
Microsoft Hatred, FAQ
Xah Lee, 20020518
Question: U.S. Judges are not morons, and quite a few others are
not morons. They find MS guilty, so it must be true.
Answer: so did the German population thought Jews are morons by
heritage, to the point that Jews should be exterminated from earth
suppose i'm going to have a data structure like this:
[
[imgFullPath,(width, height)],
[imgFullPath,(width, height)],
[imgFullPath,(width, height)],
[imgFullPath,(width, height)],
...
]
should i use (width,height) or [width,height]?
what advantage i get to use n-tuple instead of the generic list?
Split File Fullpath Into Parts
Xah Lee, 20051016
Often, we are given a file fullpath and we need to split it into the
directory name and file name. The file name is often split into a core
part and a extension part. For example:
'/Users/t/web/perl-python/I_Love_You.html'
becomes
Bryan wrote:
> mr. xah... would you be willing to give a lecture at pycon 2006? i'm sure you
> would draw a huge crowd and a lot of people would like to meet you in
> person...
>
> thanks.
I'd be delight to.
My requirements are: 1 cup of fat-free milk, free, and free pizza.
Xah
[EMAIL PROTE
Xah Lee wrote:
> > In Perl, spliting a full path into parts is done like this:
Dr.Ruud wrote:
> And then follows Perl-code that only works with an optional .html
> "extension",
Thanks for the note. I've corrected it here:
http://xahlee.org/perl-python/split_fullp
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
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_di
Python doc problem:
http://python.org/doc/2.4.2/lib/os-file-dir.html
makedirs( path[, mode])
Recursive directory creation function. Like mkdir(), but makes all
intermediate-level directories needed to contain the leaf directory.
Throws an error exception if the leaf directory already ex
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
gi
> Xah Lee, on Aug 22, 2:43 pm wrote:
> Unix, RFC, and Line Truncation
> http://xahlee.org/UnixResource_dir/writ/truncate_line.html
Steve wrote:
> I've seen this argument before. There's at least one VERY good reason
> to hard-code linebreaks in text: to preserve a cover
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.
[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
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
One-Liner Loop in Functional Style
Xah Lee, 200510
Today we show a example of a loop done as a one-liner of Functional
Programing style.
Suppose you have a list of file full paths of images:
/Users/t/t4/oh/DSCN2059m-s.jpg
/Users/t/t4/oh/DSCN2062m-s.jpg
/Users/t/t4/oh/DSCN2097m-s.jpg
/Users/t
Thomas Bellman wrote:
>try:
> os.makedirs("/tmp/trh/spam/norwegian/blue/parrot/cheese")
>except os.error, e:
> if e.errno != errno.EEXIST:
> raise
This is what i want. Thanks.
(the doc needs quite some improvement...)
Xah
[EMAIL PROTECTED]
∑ http://xahlee.org/
-
A Haskell A Day: Manifesto
This is my learning notes on Haskell. I call it a-Haskell-a-day. I've
been programing since 1992, and am a top expert at the Mathematica↗
language. I've long wanted to learn Haskell. It is my habit to write
down what i'm learning. I will send out a small tip of what i ha
in some online documentations, for examples:
http://perldoc.perl.org/perlref.html
http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html
http://www.haskell.org/hawiki/HaskellDemo
the codes are syntax colored.
Is there a tool that produce codes in html with syntax coloring?
Thanks.
well, in the past couple of days i started my own:
http://xahlee.org/emacs/notes.html
but i'm sure something like it exists.
Btw, the elisp intro by
Robert J Chassell. At:
http://www.gnu.org/software/emacs/emacs-lisp-intro/
is extremely well written.
(and so is the elisp reference)
Bravo to GNU
the Journey of Foreign Characters thru Internet
Xah Lee, 20051101
There's a bunch of confusions about the display of non-ascii characters
such as the bullet "•". These confusions are justifiable, because the
underlying stuff is technology, computing technologies, are in a laymen
s
Python Doc Problem Example: gzip
Xah Lee, 20050831
Today i need to use Python to compress/decompress gzip files. Since
i've read the official Python tutorial 8 months ago, have spent 30
minutes with Python 3 times a week since, have 14 years of computing
experience, 8 years in mathema
[EMAIL PROTECTED] wrote:
«I want to read a little bit about sorting in Python (sorted() and
method sort()). But I can't seem to find anything in the documentation
at the homepage?»
if you want some detailed account on the sort method, see:
http://www.xahlee.org/perl-python/sort_list.html
Xah
[
1 - 100 of 525 matches
Mail list logo