程序人生

          撰寫生活代碼,等待編譯美好人生
          隨筆 - 48, 文章 - 0, 評論 - 29, 引用 - 0
          數據加載中……

          2007年12月3日

          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 閱讀(783) | 評論 (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 閱讀(441) | 評論 (1)編輯 收藏

          感覺我是無賴

          這種感覺不好。。

          posted @ 2007-12-03 22:04 405 Studio 閱讀(262) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 基隆市| 疏附县| 滕州市| 阿巴嘎旗| 长垣县| 英德市| 塔河县| 平顶山市| 开化县| 睢宁县| 北宁市| 葵青区| 田东县| 本溪市| 腾冲县| 无为县| 昆山市| 镇康县| 孙吴县| 佛山市| 鲜城| 永丰县| 汉川市| 台东县| 塔河县| 邵东县| 桂平市| 安新县| 西乌珠穆沁旗| 绥滨县| 公主岭市| 郸城县| 卢氏县| 涪陵区| 新郑市| 尤溪县| 博客| 大渡口区| 莱芜市| 清原| 南漳县|