Django 1.6 最佳实践: 如何正确使用 CBVs (Class-based views)
Class-based views是Django为解决建站过程中的常见的呈现模式而建立的. 在这节中, 我们着重讲一下CBVs的使用技巧和一般原则.
1. CBVs的使用原则
代码越少越好永远不要重复代码View应当只包含呈现逻辑, 不应包括业务逻辑保持view逻辑清...
分类:
其他好文 时间:
2014-05-22 23:22:14
阅读次数:
299
主要理解新与旧到底在哪里 这样也就理解了 深浅拷贝
先说说赋值,其实python中的赋值其实是赋值了一个引用,例如:
foo1=1.0
foo2=foo1
用操作符is判断时,你可以发现结果是true,是因为python是先创建了一个对象1.0,然后这个对象的引用又被赋值给了foo1和foo2,但是如果是这样:
foo1=1.0
foo2=1.0
这时你会...
分类:
编程语言 时间:
2014-05-22 23:17:34
阅读次数:
340
在DAG中DFS中顶点的出栈顺序即逆拓扑序。
def topological_sort( graph ):
is_visit = dict( ( node, False ) for node in graph )
li = []
def dfs( graph, start_node ):
for end_node in...
分类:
编程语言 时间:
2014-05-22 23:12:10
阅读次数:
487
Pexpect模块:http://www.ibm.com/developerworks/cn/linux/l-cn-pexpect1/
ConfigParser模块:http://blog.chinaunix.net/uid-25890465-id-3312861.html
logging模块:http://kenby.iteye.com/blog/1162698
threading模块...
分类:
编程语言 时间:
2014-05-22 22:38:36
阅读次数:
358
Problem 3: Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
求出最大素因子
我的python代码如下:
又不懂的,或者更好的可以留言,大家互相...
分类:
其他好文 时间:
2014-05-22 18:40:17
阅读次数:
198
import re
data = open('a.txt')
fh = open('b.txt', 'w')
"""Search the string begining with '【'"""
p = re.compile(r'\s*[\u3010]')
for each_d in data:
if re.match('\s*3\d{4}', each_d):
...
分类:
编程语言 时间:
2014-05-22 17:26:17
阅读次数:
293