2013年9月10日

python some beautiful code

摘要: 1:{ i:i for i in range(i)}2:dict([(i,i) for i in range(i)])# a = {'1': [1, 2, 5], '3': [6, 7], '2': [3, 4]} --> {1: '1', 2: '1', 3: '2', 4: '2', 5: '1', 6: '3', 7: '3'}{ x:i for i,j in monster_group.items() for x in j 阅读全文

posted @ 2013-09-10 15:23 tiger4py 阅读(128) 评论(0) 推荐(0) 编辑

2013年7月16日

virtual box 64 操作系统

摘要: 小 知识点 除了 各种版本对了,之外 ,还需要 将 bios 中 cpu virtual 那东东 变成 enable、 阅读全文

posted @ 2013-07-16 11:55 tiger4py 阅读(121) 评论(0) 推荐(0) 编辑

2013年7月2日

从内存读取更新数据

摘要: 最近内存越来越大,信息,尽量存在内存中 ,可以加快速度,现在先写一个 大体 思路。很多细节。待更新。先从网上,看下了sqlite 的使用 。很轻量的数据库。拿来做测试,也很方便查看。思路 就是 :从内存中拿,如果内存没有就从数据库中取。每次更新数据库的时候 更新一下内存中的数。#!/usr/bin/env python# -*- coding: utf-8 -*-import sqlite3cx = sqlite3.connect("E:/sqlite/test.db")cu = cx.cursor()def data_from_sql(sql_id): sql = &qu 阅读全文

posted @ 2013-07-02 18:16 tiger4py 阅读(233) 评论(0) 推荐(0) 编辑

2013年7月1日

python 下载包什么的 window

摘要: 1:setuptools2:环境变量 E:\Python27\Scripts;3:easy_install ipythoneasy_install --upgrade pylinthttp://peak.telecommunity.com/DevCenter/EasyInstall easy_install 文档。。。有了这个东西,xp下 也能和linux下一样了。曾经遇到的一个问题是:setuptools 太旧,导致很多库 查不到。需要更新setuptools。其中原理 估计是跟 linux 更新 源 的 url差不多。 阅读全文

posted @ 2013-07-01 15:58 tiger4py 阅读(206) 评论(0) 推荐(0) 编辑

2013年6月21日

python metaclass

摘要: 有一篇很好的讲解http://blog.jobbole.com/21351/ 我所写的方便自己学习的例子。#coding:utf8class Application(object): def __init__(self): super(Application, self).__init__() self.items = {'key1':'value1','key3':'value3','key2':'value2'} def init_model(self,model_cls): for attr 阅读全文

posted @ 2013-06-21 10:29 tiger4py 阅读(171) 评论(0) 推荐(0) 编辑

2013年6月18日

python 装饰器

摘要: def test_a(func): def test_aa(request,*args,**argw): print 1 print func.__name__ print args print argw func(request,*args,**argw) return test_aadef test_b(func): def test_aac(request,*args,**argw): print 2 print func.__name__ print arg... 阅读全文

posted @ 2013-06-18 16:23 tiger4py 阅读(179) 评论(0) 推荐(0) 编辑

2013年5月11日

一些常用模块

摘要: random每次使用random,都是到网上查。所以还是整理下吧。 根据 (我自己用的最多得情况写吧)1. random.sample() 这函数的 作用 非常大。不是它可以得到几个样本,而是 它得到的样本,不会重复。实际中用得非常多。2.random.choice()3.random.randrange([5,10,2]) 等价 range.choice(range(5,10,2)) 实际中,一般需要把 需要随机的数先准备出来,在 choice.4.random.shuffle() 将序列打乱。用得不算多。可能是 random 选取数 有固定的算法,有时候会重复,所以先打乱下,在选择吧。可. 阅读全文

posted @ 2013-05-11 06:59 tiger4py 阅读(123) 评论(0) 推荐(0) 编辑

2013年3月27日

mongoengine 学习 笔记

摘要: 一边做项目,一边做笔记的。这习惯不好,做项目的时候,不酣畅,但我 一做完项目就忘了,其中的想法。回头也找不出头绪了。1: 创建model (整个项目的部署 如同django) 有:setting,url,model,viewsimport mongoengine as modelsclass Project(models.Document): pass class Respondent(models.DynamicDocument): pass这里的Docment.DynamicDocument.区别在于DynamicDocument可扩展.respondente的动态属性... 阅读全文

posted @ 2013-03-27 09:27 tiger4py 阅读(900) 评论(0) 推荐(0) 编辑

2013年1月30日

ubuntu10.04 + nginx + uwsgi + django +virtual + hg + mysql +mongodb

摘要: 接触linux时日不多,所以配起来比较麻烦。仅此记录我的步骤。公司要求离线安装,所以都是下载好了(最好下载deb),然后安装这里没太多细节。1:首先虚拟机设置共享。关键点: mount cdrom1 /mnt/xxx 。添加的盘片VboxGuestAdition 加载到cdrom1 然后挂载2:安装hg http://www.cnblogs.com/xiazh/archive/2012/07/31/2616474.htmltar -zvxf mercurial-1.7.1.tar.gzerror: command 'gcc' failed with exit status 1s 阅读全文

posted @ 2013-01-30 16:41 tiger4py 阅读(432) 评论(0) 推荐(0) 编辑

导航