Christmas names
Dec 15
2009
2009
>>>from nltk.corpus import wordnet as wn >>>wn.synsets('Christmas')[0].lemma_names ['Christmas', 'Christmastide', 'Christmastime', 'Yule', 'Yuletide', 'Noel']
my web space
>>>from nltk.corpus import wordnet as wn >>>wn.synsets('Christmas')[0].lemma_names ['Christmas', 'Christmastide', 'Christmastime', 'Yule', 'Yuletide', 'Noel']
import re greeting = "Merry Christmas" greeting_list = map(chr, [ord(i) - len(greeting) - 1 for i in greeting]) greeting_list = set(filter(lambda x: re.match('[a-z]|[A-Z]', x), greeting_list)) # greeting_list is set(['c', 'b', 'd', 'i', 'Q', 'U', 'Y', 'X']) # the 1st 3 elements are not clear to me: c,b,d # 'i' means 'I', 'Q' means 'question', 'U' means 'you', 'Y' means 'why', 'X' means 'Christmas' # which makes the compound: 'I question you - why Christmas?'
Right?
Find your Trac path:
python -c’import trac;print trac’
Edit env.py on line 598:
1 2 3 4 5 6 | if needs_upgrade: try: os.system("/usr/bin/trac-admin %s upgrade" % env_path) except TracError: raise TracError(_('The Trac Environment needs to be upgraded.\n\n' 'Run "trac-admin %(path)s upgrade"', path=env_path)) |
Restart Trac daemon ot whatever http server is serving it.
Python
import re _char = re.compile(r'\w') ''.join([chr(i) for i in xrange(65,122) if _char.match(chr(i))]) # or just: import string string.ascii_letters string.ascii_lowercase string.ascii_uppercase
Ruby
(65..122).to_a.map{ |e| e.chr =~ /\w/ && e.chr }.compact.to_s
Perl
$chars .= chr() =~ /\w/ ? chr() : q{} for 65..122;
I don’t like the mess of Ruby, and Perl.
Ruby
arr = (1..10).to_a arr.select{ |e| e % 2 != 0 }
Python
arr = range(1,11) [e for e in arr if e % 2]
Perl
@arr = (1..10); grep($_ % 2, @arr);
#!/usr/bin/python import re hex_encode = lambda x: ("&#%i;" * len(x)) % (tuple(map(ord, re.findall('.', x)))) # hex_encode("root@example.com") =>; # root@vidul.com
Ruby slice:
a = [1, 2, 3, 4, 5, 6] a[0..-1] # [1, 2, 3, 4, 5, 6] a[(0..-1)] # tha same
Python slice:
a = [1, 2, 3, 4, 5, 6] a[:-1] # [1, 2, 3, 4, 5] a[:] # [1, 2, 3, 4, 5, 6] a[0:len(a):2] # [2, 4, 6] Nice, isn't it?
String methods:
"a".upto("z"){ |i| puts i }
a = String.new "a" 0.upto(0){ p a } 1.upto(25){ p a.next! }
Range method:
("a".."z").each{ |e| puts e }
Perl
($a, $b) = (1, 2); @arr = (1, 2);
Python
a, b = 1, 2 arr = 1, arr = 1,2
Ruby
a, b = 1, 2 arr = 1, 2 arr = 1,2, *[11,22] # the same as arr = [1,2, [11,22]].flatten
Comment