Search the web
Sign In
New User? Sign Up
perl-python
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 33 - 66 of 127   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Simplify | Expand   (Group by Topic) Author Sort by Date ^
33
# -*- coding: utf-8 -*- # Python # Matching string patterns # # Sometimes you want to know if a string is of # particular pattern. Let's say in your website #...
Xah Lee
p0lyglut
Offline Send Email
Feb 1, 2005
8:30 pm
35
it's interesting to note that the string replace method .replace() does so by returning a copy, as opposed to inplace. in OOP parlance, such would be called...
Xah Lee
p0lyglut
Offline Send Email
Feb 3, 2005
3:25 pm
36
previously we had a code that find & replaces strings in a dir. http://xahlee.org/perl-python/find_replace_dir.html now suppose in your html file, you want to...
Xah Lee
p0lyglut
Offline Send Email
Feb 3, 2005
3:52 pm
38
# -*- coding: utf-8 -*- # Python # suppose you want to fetch a webpage. from urllib import urlopen print ...
Xah Lee
p0lyglut
Offline Send Email
Feb 4, 2005
6:46 pm
39
20050207 text pattern matching # -*- coding: utf-8 -*- # Python # suppose you want to replace all strings of the form # <img src="some.gif" width="30"...
Xah Lee
p0lyglut
Offline Send Email
Feb 7, 2005
6:45 pm
42
the following should be the correct script, implemented with a list of couples. # -*- coding: utf-8 -*- # Python import os,sys mydir=...
Xah Lee
p0lyglut
Offline Send Email
Feb 9, 2005
9:22 pm
43
a year ago i wrote this perl program as part of a larger program. as a exercise of fun, let's do a python version. I'll post my version later today. # combo(n)...
Xah Lee
p0lyglut
Offline Send Email
Feb 10, 2005
10:50 pm
44
here's the answer. http://xahlee.org/perl-python/combinatorics.html Python is so sweet! # -*- coding: utf-8 -*- # Python def combo (n): '''returns all possible...
Xah Lee
p0lyglut
Offline Send Email
Feb 11, 2005
6:33 am
45
# -*- coding: utf-8 -*- # Python # David Eppstein of the Geometry Junkyard fame gave this elegant # version for returing all possible pairs from a range of n...
Xah Lee
p0lyglut
Offline Send Email
Feb 11, 2005
10:59 pm
46
here's a interesting real-world algoritm to have fun with. attached below is the Perl documentation that i wrote for a function called “reduce”, which is...
Xah Lee
p0lyglut
Offline Send Email
Feb 15, 2005
6:50 am
47
here are the solutions: Perl code: sub reduce ($$) { my %hh= %{$_[0]}; # e.g. {'1,2'=>[1,2],'5,6'=>[5,6],...} my ($j1,$j2)=($_[1]->[0],$_[1]->[1]); # e.g....
Xah Lee
p0lyglut
Offline Send Email
Feb 15, 2005
12:42 pm
48
someone supplied this version of reduce: def reduce2( pairings, pair ): result={} for i,j in pairings.itervalues(): if i in pair: i=pair[0] if j in pair:...
xah lee
p0lyglut
Offline Send Email
Feb 16, 2005
9:52 am
49
... That was me, formerly reading posts via web and now joining the group at the encouragement of Mr. Lee to continue this discussion. ... the ... Thanks!...
drguzler
Offline Send Email
Feb 16, 2005
9:23 pm
50
here's another interesting algorithmic exercise, again from part of a larger program in the previous posts. Here's the original Perl documentation: =pod ...
xah
p0lyglut
Offline Send Email
Feb 17, 2005
11:37 pm
51
here's the answer to yesterday's exercise. ... # Perl code sub merge($) { my @input = @{$_[0]}; my @interm; # array of hashs # chop the first value of @input...
xah lee
p0lyglut
Offline Send Email
Feb 19, 2005
11:39 am
52
erratum: The GOTO statement translation from Perl has been messed up. This block: for group in interm: for newcoup in fin: for k...
xah lee
p0lyglut
Offline Send Email
Feb 20, 2005
9:17 am
53
previously we had scripts that replace strings for all files in a dir. See http://xahlee.org/perl-python/findreplace_multi_pairs.html i modified the script and...
xah lee
p0lyglut
Offline Send Email
Feb 22, 2005
2:11 am
54
another functional exercise with lists. Again, it is part of a larger program. I'm proceeding to port the whole thing to Python as a exercise. We've done about...
xah lee
p0lyglut
Offline Send Email
Feb 24, 2005
11:09 am
55
(previous post is crude and sloppy filled with errors. Here's a better, corrected version.) ... another functional exercise with lists. Here's the perl...
xah lee
p0lyglut
Offline Send Email
Feb 24, 2005
11:51 am
56
[SOLUTIONS BELOW] I suspect you are looking for an answer that makes use of the previous exercises, like so: def parti (list, equalFunc): n = len(list) equals...
drguzler
Offline Send Email
Feb 25, 2005
1:01 am
57
Here's the answer to the generic equivalence partition exercise. http://xahlee.org/perl-python/gen_parti_by_equiv.html # the following solution is submitted by...
xah lee
p0lyglut
Offline Send Email
Feb 26, 2005
12:10 pm
58
the parti one gives incorrect answer for li=[4, 4, 1, 1, 2, 0, 0, 1, 3], with == as predicate.) The parti_custom looks great. Thanks. Xah Lee ... On Feb 24,...
xah lee
p0lyglut
Offline Send Email
Feb 26, 2005
12:10 pm
59
20050226 exercise: generate all possible pairings given a list that is a set partitioned into subsets, generate a list of all possible pairings of elements in...
xah lee
p0lyglut
Offline Send Email
Feb 27, 2005
2:02 am
60
Ah, a small typo fixes it, for the sake of intellectual completeness: < equals += [(i,i) for i in range(1,n)] ... - Sean ... From: xah lee...
Sean Gugler
drguzler
Offline Send Email
Feb 28, 2005
11:04 pm
61
Answer to the previous exercise. http://xahlee.org/perl-python/generate_pairings.html # perl sub genpair ($) { my $partiSet = $_[0]; my @result; for (my $head...
xah lee
p0lyglut
Offline Send Email
Mar 2, 2005
4:07 am
62
I have a bunch of files encoded in gb18030 and i need to convert it to utf-16. Can i do that with Pyton? Yes. Such facilities is built-in in Python version...
Xah Lee
p0lyglut
Offline Send Email
Mar 8, 2005
12:20 am
63
Is it possible in Python to create a function that maintains a variable value? Something like this: globe=0; def myFun(): globe=globe+1 return globe The answer...
xah lee
p0lyglut
Offline Send Email
Mar 8, 2005
3:18 pm
64
here's the code. ... # python import os mydir= '/Users/t/web/p/monkey_king' def changeEncoding(filePath): '''take a full path to a file as input, and change...
xah lee
p0lyglut
Offline Send Email
Mar 9, 2005
12:03 pm
65
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical,...
xah lee
p0lyglut
Offline Send Email
Mar 9, 2005
1:18 pm
66
previously we had find & replace string in a file: http://xahlee.org/perl-python/find_replace.html though, that code won't work for non-ascii files. For...
xah lee
p0lyglut
Offline Send Email
Mar 10, 2005
2:03 am
Messages 33 - 66 of 127   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help