Skip to main content

Posts

open social

open social is about api, also about concept, or vision. you can guess what's this for based on the naming -- social on the internet in a more open way. is it really a good idea? it based on the assumption that human being has common needs for socialization.

Declassified Chairman Mao

I watched this program on History channel. The show mainly focuses on what have happened around him after 1949. Nothing is new. It is a short documentary with a couple of oversea Chinese scholars interviewed, sharing their experiences and thoughts on the Culture Revolutionary. Most of the video clip is in low quality. Here is a brief introduction of this program : "Mao was the 20th century's answer to Napoleon: a brilliant tactician, a political and economic theorist, and a statesman who ruled a billion people for three decades. In death he has become divine, worshiped as a god in a godless country. Considering who and what he ruled, Mao, with his Little Red Book, might just be the single most powerful human being who ever lived."

python help

>>> dir(string) ['Formatter', 'Template', '_TemplateMetaclass', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_float', '_idmap', '_idmapL', '_int', '_long', '_multimap', '_re', 'ascii_letters', 'ascii_lowercase', 'ascii_uppercase', 'atof', 'atof_error', 'atoi', 'atoi_error', 'atol', 'atol_error', 'capitalize', 'capwords', 'center', 'count', 'digits', 'expandtabs', 'find', 'hexdigits', 'index', 'index_error', 'join', 'joinfields', 'letters', 'ljust', 'lower', 'lowercase', 'lstrip', 'maketrans', 'octdigits', 'printable', 'punctuation', 'replace', 'rfind', 'rindex', 'rjust',

python strings

>>> 'bbb'; "fffff"; 'bbb' 'fffff' >>> """this is a lines of lines of comments""" 'this is a\nlines of lines of\ncomments' >>> 'u\34ee', '\x3e', '\oxx' ('u\x1cee', '>', '\\oxx') >>> '\033','\o33' ('\x1b', '\\o33') >>> 'u\23ee','\x3e','\032' ('u\x13ee', '>', '\x1a') >>> u'\xf8', u'nci\u00f8de' (u'\xf8', u'nci\xf8de') >>> r"c:\path\to\files"; 'c:\\path\\to\\files' >>> str(3.14),str(44) ('3.14', '44') >>> s = 'a line of seq' >>> s.decode('utf-8'), s.encode('utf-8') (u'a line of seq', 'a line of seq') >>> chr(33), unichr(345) ('!', u'\u0159') >>> s.find('li&#

python sets

>>> s=set([1,2,3,4,5,1,2]) >>> s set([1, 2, 3, 4, 5]) >>> fs=frozenset(s) >>> fs frozenset([1, 2, 3, 4, 5]) >>> fs.issubset(s);fs.issuperset(s) True True >>> t=set([1,2,6,7,8,9]) >>> s.intersection(t), s&t (set([1, 2]), set([1, 2])) >>> s.union(t), s|t (set([1, 2, 3, 4, 5, 6, 7, 8, 9]), set([1, 2, 3, 4, 5, 6, 7, 8, 9])) >>> s.difference(t), s-t (set([3, 4, 5]), set([3, 4, 5])) >>> s.symmetric_difference >>> s.symmetric_difference(t), s^t (set([3, 4, 5, 6, 7, 8, 9]), set([3, 4, 5, 6, 7, 8, 9])) >>> s.copy() set([1, 2, 3, 4, 5]) >>> fs.copy() frozenset([1, 2, 3, 4, 5]) >>> r=s.copy() >>> r set([1, 2, 3, 4, 5]) >>> s.update(t), s|=t SyntaxError: illegal expression for augmented assignment >>> s.update(t); s|=t >>> s set([1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> s.add(1) >>> s.add(44) >>> s set([1, 2, 3, 4, 5

python dictionaries

>>> d = {'x':34,'y':'fff','z':4.6} >>> d['y'], len(d), d.items(), d.keys() ('fff', 3, [('y', 'fff'), ('x', 34), ('z', 4.5999999999999996)], ['y', 'x', 'z']) >>> c = d.copy >>> c >>> d.has_key('x'), d.values() (True, ['fff', 34, 4.5999999999999996]) >>> d {'y': 'fff', 'x': 34, 'z': 4.5999999999999996} >>> i=d.iteritems();i.next() ('y', 'fff') >>> i=d.iterkeys();i.next() 'y' >>> i=d.itervalues();i.next() 'fff' >>> d.popitem() ('y', 'fff') >>> d {'x': 34, 'z': 4.5999999999999996} >>>

python squences

>>> l = [1,'b', [3,4.],5,6] >>> t = (8,9, ['a',1],4,5) >>> l = list(t); t = tuple(l) >>> type(l), type(t) >>> l, t ([8, 9, ['a', 1], 4, 5], (8, 9, ['a', 1], 4, 5)) >>> l = [1,'b', [3,4.],5,6] >>> s = range(20) >>> s [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>> i = iter(t); i.next() 8 >>> l[2][1],l[-3][-1] (4.0, 4.0) >>> s = 'what a nice day!' >>> '-' * 5 '-----' >>> len(s), s[2:5], s[:], s[4:], s[4], s[:-2] (16, 'at ', 'what a nice day!', ' a nice day!', ' ', 'what a nice da') >>> s[1:3:2], s[::2], s[::-1] ('h', 'wa iedy', '!yad ecin a tahw') >>> max(s), min(s), 'a' in s, 'a' not in s ('y', ' ', True, False) >>> s 'what a nice day!' >>> s.i