程序人生

          撰寫生活代碼,等待編譯美好人生
          隨筆 - 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 閱讀(785) | 評論 (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 閱讀(446) | 評論 (1)編輯 收藏

          感覺我是無賴

          這種感覺不好。。

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

          主站蜘蛛池模板: 磴口县| 任丘市| 竹北市| 普兰县| 阆中市| 苏尼特左旗| 涿鹿县| 桃园市| 涡阳县| 思南县| 黄浦区| 新兴县| 综艺| 永丰县| 巩义市| 乐东| 客服| 香河县| 青铜峡市| 松原市| 额济纳旗| 额敏县| 屏东县| 长武县| 吴忠市| 通江县| 海宁市| 南开区| 泸定县| 宝应县| 游戏| 嘉禾县| 黎城县| 洛阳市| 玉树县| 德清县| 增城市| 金昌市| 浑源县| 安丘市| 兴安县|