Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
whille authored and whille committed Jun 3, 2012
1 parent 215809e commit 73372a2
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions python.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# YAML
---
main:
if __name__ == "__main__":
main()
Expand All @@ -13,9 +11,11 @@ __buildin__:
callable() #return True/False
repr() vs. eval()
locals() :dict
setattr(object, name, value)
setattr(object, name, value):
setattr(x, 'y', v) --> x.y = v
getattr(object, name[, default]) -> value
sorted()

import:
import X
reload(X)
Expand All @@ -32,14 +32,16 @@ data structure:
ex: dict(('key%s' %i, 'value%s' %i) for i in xrange(10))
d = dict(**kwargs):
ex: dict(one=1, two=2)
dic=dict(zip(ls1,ls2))
**dic: k=v,...
d["k1"]
.clear()
.keys()
.values()
.items():
["%s=%s" % (k, v) for k, v in params.items()]
dic=dict(zip(ls1,ls2))
**dic: k=v,...
.pop(k[,d]) ->v #If k is not found, d is returned if given


- list:
li = ["a", "b", "mpilgrim", "z", "example"]
Expand Down Expand Up @@ -71,6 +73,10 @@ data structure:
s.split(';'):
" ".join(s.split())
''.join(sorted('cat'))

---
class:
super(
---
nose: UT
pip install nose
Expand Down Expand Up @@ -114,6 +120,7 @@ ipython:
start: ipyhthon -pylab
virable: %env %[TAB]
%autoindent #toggle autoindent, for paste
dict?, dict??
![Shell]
%history
ex:
Expand Down Expand Up @@ -242,13 +249,17 @@ pydev:
New
/usr/bin/python2
---
limitation:
GIL: Global Interpreter Lock
sys.getcheckinterval()

---
#use yaml in python
import yaml
import yaml

stream = open("example.yaml", 'r')
print yaml.load(stream)
stream = open("example.yaml", 'r')
print yaml.load(stream)

...
---
list comprehension, lambda, decorator, descriptor, slots, generator
Bigtable, Dynamo
Expand Down

0 comments on commit 73372a2

Please sign in to comment.