程序人生

撰写生活代码,等待编译美好人生
随笔 - 48, 文章 - 0, 评论 - 29, 引用 - 0
数据加载中……

2007年6月17日

Python为自身模块添加属性

试了好半天才始出来,几经曲折,所以写下来:

A模块:
1 import sys, os
2 selfMod = __import__(__name__)
3 setattr(selfMod, "field""value")


在B模块中调用
1 import A
2 print A.field
输出: value

模块A的这种写法与在模块A中直接写field = "value"的效果是一样的。这看起来似乎多余,但是在某些特殊的情况下可以用该方法动态设置当前模块的属性。



posted @ 2008-05-20 02:21 405 Studio 阅读(763) | 评论 (0)编辑 收藏

蔬菜沙拉

前几天跟朋友去吃了一次蔬菜沙拉。做的很精致,但并不合我的口味,但朋友很喜欢。
今天闲暇之际研究一下“沙拉”的来源:
google了一下"define:沙拉"

沙拉(香港称为沙律)通常是配菜,有时会作为一道主菜。 

不详细,在answers.com找了一下:

Originally derived from the Latin sal  for  salt, meaning something dipped into salt. Now normally a dish of uncooked vegetables; either a mixed salad or just one item (commonly lettuce or tomato). 
的确,我们吃的都是卷心菜(当时我以为卷心菜就是生菜 -_-|||)和小西红柿。

食物文化百科:
Although the ancient Greeks and Romans did not use the word "salad," they enjoyed a variety of dishes with raw vegetables dressed with vinegar, oil, and herbs. Pliny the Elder in Natural History, for instance, reported that salads (acetaria) were composed of those garden products that "needed no fire for cooking and saved fuel, and which were a resource to store and always ready" (Natural History, XIX, 58). They were easy to digest and were not calculated to overload the senses or stimulate the appetite.
...........
...........

最终,我在怀疑是不是中国凉拌传入西方之后变味了的结果。

posted @ 2007-12-05 01:43 405 Studio 阅读(413) | 评论 (1)编辑 收藏

感觉我是無賴

这种感觉不好。。

posted @ 2007-12-03 22:04 405 Studio 阅读(249) | 评论 (0)编辑 收藏

Windows DB2 Express-C 9 启动不了的原因

这几天想尝试一下 DB2 Express-C 9 ,找了个Windows的版本,几个"下一步"几个确定之后就装玩了. Reboot以下以为可以开始探索DB2 9了.没想到DB2却怎么都启不来.
折腾了几天才知道原来DB2 服务的启动还跟系统的一些其他服务有联系于是把在服务列表中把Server服务启动了再启动DB2, 启动成功!

posted @ 2007-08-04 17:05 405 Studio 阅读(690) | 评论 (1)编辑 收藏

Vim的16进制模式

今天有人问我VIM能不能像UE那样进行16进制编辑以,一时间没有答上来。执行了一下 :help hex才发现原来用 %!xxd 命令实现。为了方便,在vimrc上做了个map,实现了了<leader> + h切换文本模式和16进制模式,虽然简单,但是很有用 :)

"To hex modle
let s:hexModle = "N"
function! ToHexModle()
  if s:hexModle == "Y"
    %!xxd -r
    let s:hexModle = "N"
  else
    %!xxd
    let s:hexModle = "Y"
  endif
endfunction

map 
<leader>h :call ToHexModle()<cr>

在使用上面这段代码之前,你得确定你设置了<leader>且与你原来的键盘映射不冲突。

posted @ 2007-06-17 15:01 405 Studio 阅读(3839) | 评论 (0)编辑 收藏