multitaskmultitask allows Python programs to use generators (aka coroutines) to perform cooperative multitasking and asynchronous I/O. Applications written using multitask consist of a set of cooperating tasks that yield to a shared task manager whenever they perform a (potentially) blocking operati ...
Polymorphic Associations with SQLAlchemySQLAlchemy 老大展示怎么用 sqlalchemy 实现 rails 的 Polymorphic Associations 顺便看了下 Rails 所谓Polymorphic Associations 的介绍,才发现其实就是我很早就介绍过的 django 的 content-type app 所干的事情,app 就是插件的意思。
- 04:28
- 浏览 (436)
- 评论 (0)
- 分类: sqlalchemy
Python and vim: Two great tastes that go great together用 python 扩展 vim ,想法倒是不新,不过第一次看到 tutotial 。记得 tocer 说过要用 python 写个 vim 库的,不知道有没有进展哈,呵呵。
http://dis.4chan.org/read/prog/1180084983/哈哈,有点意思,再加一个:Python 2.5 programmer:def fact(x): return x * fact(x - 1) if x > 1 else 1print fact(6)
有的时候在 blog 里写 wiki,有的时候在 wiki 里写 blog,有的时候在 blog 里发在 wiki 里写的 blog ;-)
写 model 的时候发现有些东西在重复,第一反应就是写个基类,把这些重复的东西拿出来,然而 Model 类之间继承却不是那么方便的,应该会影响到 ORM 的行为。怎么办呢?幸好 python 有多重继承。下面就是项目中做这些重复事情的类:class ModelMixin(object): def save(self): if not self.id: # creation time if hasattr(self, 'pubdate'): self.pubdate = datetime.now() ...
建一个项目 newformstutorials ,建一个 app blog ,在 blog 的 models 中定义个:class Article(models.Model): title = models.CharField(u'标题', maxlength=255) author = models.CharField(u'作者', maxlength=20) hits = models.IntegerField(u'点击数', default=0, editable=False) content = models.TextField(u'内容')配置好数据库,把 n ...
又用 django 做了个项目,因为主要都是后台的东西,所以决定启用 django 的 newforms admin 分支!(不过这里我不是推荐大家现在就开始用 newforms admin 分支,如果没有把握,最好是抱着玩玩的态度先,我在开发过程中就改掉它好几个bug)
newforms admin 分支是用 newforms 来重构 admin 模块,也顺便改变了一些设计决策,大大增强了 admin 的可定制性。首先 newforms 的应用,成功分离了 db field、form field、widget 三个部分,db field 属于 ORM ,主要负责 model 相关的事务 ...
"""
要编写复杂软件又不至于一败涂地的唯一方法就是用定义清晰的接口把若干简单模块组合起来。
"""
抽象的说,其实接口、契约、协议、界面等等概念说的差不多都是一个意思。
作为如此流行的被大规模使用的语言,python 一直没有这么个东西的标准实现,实在是一种遗憾,当然第三方的实现 zope.interface 其实早就在 zope 和 twisted 中大量应用了。
python 3000 中正在讨论的:
pep 3119 Introducing Abstract Base Classes;
pep 3124 Ov ...
- 14:35
- 浏览 (933)
- 评论 (1)
- 分类: python3000
- 发布在 Python 圈子
好久没写 blog 了,现在毕业论文终于敲定,可以长舒一口气 ;-)写论文的时候,rst 可真是帮我不少忙,不过学校规定得交 doc 的版本,包括论文的格式什么的都是针对 msword 来说的,只好用 rst 生成 html ,然后拷贝到 msword。看到同学直接在 msword 里写论文,最后再痛苦地调整格式,窃喜 ;-)继续我们可爱的python的写作,不过写到现在感觉自己还是不习惯写入门的东西,总是不自觉地想用最简洁的语言把所有东西都说出来(不过这倒符合python的哲学 = =" ),只好努力压下许多 python 的好东东了。
- 浏览: 37310 次
- 性别:


- 详细资料
搜索本博客
最近加入圈子
最新评论
-
metaclass in python (par ...
应该有django的Model
-- by 差沙 -
老子毕业了
哈哈,恭喜
-- by beyking -
新的 pep !
晕死,这种符号能打出来吗?
-- by towjzhou -
SQLAlchemy Examples
好,需要这样的例子。自己用只能是从文档中获取一些,高级的用法,需要花时间看源码, ...
-- by xlp223 -
强大的 sqlalchemy
sql是个基础,脱离它去谈orm,有如纸上谈兵。
-- by xlp223






评论排行榜