W!o 的派生‧十日談之《十》

常言道︰『一圖勝千言』,此圖

金庸、徐志摩、瓊瑤、錢學森

或許容易『考證』,想那紀曉嵐寫『閱微草堂筆記』二十四卷,卻尋不著這段『史實』︰

【俄國使節】

我俄人,騎奇馬,張長弓 ,

單戈成戰 ;

琴瑟琵琶八大王 ,王王在上。

【紀曉嵐】

爾人你 ,襲龍衣 ,偽為人 ,

合手即拿;

魑魅魍魎四小鬼 ,鬼鬼在邊。

它載之於《幽默心理學: 思考與研究》,可能來自《 紀曉嵐傳奇》 ,雖早想『存疑』忘卻,無奈金庸說,這個『絕對』出自『黃蓉』之父『東邪黃藥師』︰

琴瑟琵琶,八大王一般頭面

魑魅魍魎,四小鬼各自肚腸

卻又似出於『司馬翎』之筆,後有『查良鏞』先生『修訂』版本,自己去『華山論劍』,以圖小說有個『合情依理』的…,只得

【橫批】

性感情忘,四季心總苦計量。

心初生,其心,青心,恐心亡。

A-Void

A Void, translated from the original French La Disparition (literally, “The Disappearance”), is a 300-page French lipogrammatic novel, written in 1969 by Georges Perec, entirely without using the letter e (except for the author’s name), following Oulipo constraints.

340px-Wikipedia_HTML5

維基百科的字詞分布情況,字型越大,代表該字詞出現的機率就越大。

220px-Al-kindi-cryptanalysis

第九世紀阿拉伯博學家肯迪所著之《手稿上破譯加密消息

190px-SNA_segment

220px-Dancing_men.svg

福爾摩斯歸來記》中
跳舞的人》,解碼是『Never

試問『人文』與『科技』的距離有多遠呢?如果有『人文科技』的『名目』,它是用著『人文』去『裝飾』『科技』,還是將以『科技』來『研究』『人文』 ??據聞有一種『質的研究』和『量的統計』恰成『對比』!!

一本沒有『字母』 e 的書,能有什麼『奇怪』的嗎?因為這不符合於一般『文本』之『字母』的『常態分佈』!還是說『另有隱情』刻意為之的呢??或是種『文字遊戲』,就像德國詩人和劇作家席勒提出『遊戲』之理論。席勒說:『只有當人充分是人的時候,他才遊戲;只有當人遊戲的時候,他才完全是人。』。或許人類在生活中勢必受到『精神』與『物質』的雙重『束縛』,因而喪失了『理想』和『自由』。於是人們假借剩下的精力打造一個『自在』的國度,這就是『遊戲』。此種『創造性』活動,源自人類的『本能』。

那麼『字詞頻率分析』與『真偽之作考據』會有關嗎?一個時代『流行』那個時代的『語詞』,一位作家有著自己『偏愛』的某些『詞彙』,這就構成了『特定』時空人物下之『字詞使用頻率』,因而可以用它來『探究』『真偽』!或許也正是『 W!o 』為難之處,想用這個『時代言語』去表述那些『未來之事』的吧!!

齊夫定律】── 實驗顯示
Zipf’s law states that given some corpus of natural language utterances, the frequency of any word is inversely proportional to its rank in the frequency table. Thus the most frequent word will occur approximately twice as often as the second most frequent word, three times as often as the third most frequent word, etc. For example, in the Brown Corpus of American English text, the word “the” is the most frequently occurring word, and by itself accounts for nearly 7% of all word occurrences (69,971 out of slightly over 1 million).

就讓我們安裝用『派生』寫的『自然語言工具箱』   Natural Language Toolkit , 玩味一下『科技』之於『人文』!

Installing NLTK

‧Install Setuptools: http://pypi.python.org/pypi/setuptools
‧Install Pip: run sudo easy_install pip
※Install Numpy (optional): run sudo pip install -U numpy
‧Install NLTK: run sudo pip install -U nltk
‧Test installation: run python then type import nltk

思索『人機界面』的未來!!

Natural Language Toolkit

NLTK is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, and an active discussion forum.

Thanks to a hands-on guide introducing programming fundamentals alongside topics in computational linguistics, NLTK is suitable for linguists, engineers, students, educators, researchers, and industry users alike. NLTK is available for Windows, Mac OS X, and Linux. Best of all, NLTK is a free, open source, community-driven project.

NLTK has been called “a wonderful tool for teaching, and working in, computational linguistics using Python,” and “an amazing library to play with natural language.”

Natural Language Processing with Python provides a practical introduction to programming for language processing. Written by the creators of NLTK, it guides the reader through the fundamentals of writing Python programs, working with corpora, categorizing text, analyzing linguistic structure, and more. The book is being updated for Python 3 and NLTK 3. (The original Python 2 version is still available at http://nltk.org/book_1ed.)

【 Python 2.X 安裝】

# 安裝『自然語言工具庫』 nltk Natural Language Toolkit
# 安裝 python-setuptools
pi@raspberrypi ~ apt-cache search setuptools python-pkg-resources - Package Discovery and Resource Access using pkg_resources python-setupdocs - setuptools plugin that automates building of docs from reST source python-setuptools - Python Distutils Enhancements (setuptools compatibility) python3-pkg-resources - Package Discovery and Resource Access using pkg_resources python3-setuptools - Python3 Distutils Enhancements (setuptools compatibility) pypy-setuptools - Easily download, build, install, upgrade, and uninstall Python packages pi@raspberrypi ~ sudo apt-get install python-setuptools
正在讀取套件清單... 完成
正在重建相依關係          
正在讀取狀態資料... 完成
下列【新】套件將會被安裝:
  python-setuptools
升級 0 個,新安裝 1 個,移除 0 個,有 0 個未被升級。
需要下載 449 kB 的套件檔。
此操作完成之後,會多佔用 1,120 kB 的磁碟空間。
下載:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-setuptools all 0.6.24-1 [449 kB]
取得 449 kB 用了 1s (335 kB/s)        
選取了原先未選的套件 python-setuptools。
(讀取資料庫 ... 目前共安裝了 181285 個檔案和目錄。)
解開 python-setuptools(從 .../python-setuptools_0.6.24-1_all.deb)...
設定 python-setuptools (0.6.24-1) ...

# 安裝 pip
pi@raspberrypi ~ sudo easy_install pip Searching for pip Reading http://pypi.python.org/simple/pip/ Best match: pip 6.1.1 Downloading https://pypi.python.org/packages/source/p/pip/pip-6.1.1.tar.gz#md5=6b19e0a934d982a5a4b798e957cb6d45 Processing pip-6.1.1.tar.gz Running pip-6.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-R8BEOr/pip-6.1.1/egg-dist-tmp-3JpLVP warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Adding pip 6.1.1 to easy-install.pth file Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin  Installed /usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip  # 安裝 nltk pi@raspberrypi ~ sudo pip install -U nltk
/usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting nltk
/usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading nltk-3.0.2.tar.gz (991kB)
    100% |████████████████████████████████| 991kB 58kB/s 
Installing collected packages: nltk
  Running setup.py install for nltk
Successfully installed nltk-3.0.2
pi@raspberrypi ~ # 顧慮『相容性』,請安裝『樹莓派』之 python-numpy  sudo apt-get install python-numpy </pre>    【 Python 3.X 安裝】 <pre class="lang:sh decode:true">pi@raspberrypi ~ sudo apt-get install python3-pip
pi@raspberrypi ~ sudo pip3 install pyyaml pi@raspberrypi ~ wget https://pypi.python.org/packages/source/n/nltk/nltk-3.0.2.tar.gz#md5=022e3e19b17ddabc0026bf0c8ce62dcf
pi@raspberrypi ~ tar -zxvf nltk-3.0.2.tar.gz  pi@raspberrypi ~ cd nltk-3.0.2/
sudo python3 setup.py install

 

【安裝測試】

pi@raspberrypi ~ $ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# 導入 nltk
>>> import nltk
>>> sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""

# 沒有下載 punkt
>>> tokens = nltk.word_tokenize(sentence)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/tokenize/__init__.py", line 101, in word_tokenize
    return [token for sent in sent_tokenize(text, language)
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/tokenize/__init__.py", line 85, in sent_tokenize
    tokenizer = load('tokenizers/punkt/{0}.pickle'.format(language))
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 781, in load
    opened_resource = _open(resource_url)
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 895, in _open
    return find(path_, path + ['']).open()
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 624, in find
    raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
  Resource 'tokenizers/punkt/PY3/english.pickle' not found.
  Please use the NLTK Downloader to obtain the resource:  >>>
  nltk.download()
  Searched in:
    - '/home/pi/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
    - ''
**********************************************************************

# 下載 punkt
>>> nltk.download()
NLTK Downloader
---------------------------------------------------------------------------
    d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
---------------------------------------------------------------------------
Downloader> d

Download which package (l=list; x=cancel)?
  Identifier> punkt
    Downloading package punkt to /home/pi/nltk_data...
      Unzipping tokenizers/punkt.zip.

---------------------------------------------------------------------------
    d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
---------------------------------------------------------------------------
Downloader> q
True

# 再次執行
>>> tokens = nltk.word_tokenize(sentence)
>>> tokens
['At', 'eight', "o'clock", 'on', 'Thursday', 'morning', 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']

# 缺少 maxent_treebank_pos_tagger
>>> tagged = nltk.pos_tag(tokens)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/tag/__init__.py", line 103, in pos_tag
    tagger = load(_POS_TAGGER)
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 781, in load
    opened_resource = _open(resource_url)
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 895, in _open
    return find(path_, path + ['']).open()
  File "/usr/local/lib/python3.2/dist-packages/nltk-3.0.2-py3.2.egg/nltk/data.py", line 624, in find
    raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
  Resource 'taggers/maxent_treebank_pos_tagger/PY3/english.pickle'
  not found.  Please use the NLTK Downloader to obtain the
  resource:  >>> nltk.download()
  Searched in:
    - '/home/pi/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
    - ''
**********************************************************************

# 表列套件及下載
>>> nltk.download()
NLTK Downloader
---------------------------------------------------------------------------
    d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
---------------------------------------------------------------------------
Downloader> l

Packages:
  [ ] abc................. Australian Broadcasting Commission 2006
  [ ] alpino.............. Alpino Dutch Treebank
  [ ] basque_grammars..... Grammars for Basque
  [ ] biocreative_ppi..... BioCreAtIvE (Critical Assessment of Information
                           Extraction Systems in Biology)
  [ ] bllip_wsj_no_aux.... BLLIP Parser: WSJ Model
  [ ] book_grammars....... Grammars from NLTK Book
  [ ] brown............... Brown Corpus
  [ ] brown_tei........... Brown Corpus (TEI XML Version)
  [ ] cess_cat............ CESS-CAT Treebank
  [ ] cess_esp............ CESS-ESP Treebank
  [ ] chat80.............. Chat-80 Data Files
  [ ] city_database....... City Database
  [ ] cmudict............. The Carnegie Mellon Pronouncing Dictionary (0.6)
  [ ] comtrans............ ComTrans Corpus Sample
  [ ] conll2000........... CONLL 2000 Chunking Corpus
  [ ] conll2002........... CONLL 2002 Named Entity Recognition Corpus
  [ ] conll2007........... Dependency Treebanks from CoNLL 2007 (Catalan
                           and Basque Subset)
  [ ] crubadan............ Crubadan Corpus
Hit Enter to continue: l
  [ ] dependency_treebank. Dependency Parsed Treebank
  [ ] europarl_raw........ Sample European Parliament Proceedings Parallel
                           Corpus
  [ ] floresta............ Portuguese Treebank
  [ ] framenet_v15........ FrameNet 1.5
  [ ] gazetteers.......... Gazeteer Lists
  [ ] genesis............. Genesis Corpus
  [ ] gutenberg........... Project Gutenberg Selections
  [ ] hmm_treebank_pos_tagger Treebank Part of Speech Tagger (HMM)
  [ ] ieer................ NIST IE-ER DATA SAMPLE
  [ ] inaugural........... C-Span Inaugural Address Corpus
  [ ] indian.............. Indian Language POS-Tagged Corpus
  [ ] jeita............... JEITA Public Morphologically Tagged Corpus (in
                           ChaSen format)
  [ ] kimmo............... PC-KIMMO Data Files
  [ ] knbc................ KNB Corpus (Annotated blog corpus)
  [ ] large_grammars...... Large context-free and feature-based grammars
                           for parser comparison
  [ ] lin_thesaurus....... Lin's Dependency Thesaurus
  [ ] mac_morpho.......... MAC-MORPHO: Brazilian Portuguese news text with
                           part-of-speech tags
Hit Enter to continue: l
  [ ] machado............. Machado de Assis -- Obra Completa
  [ ] masc_tagged......... MASC Tagged Corpus
  [ ] maxent_ne_chunker... ACE Named Entity Chunker (Maximum entropy)
  [ ] maxent_treebank_pos_tagger Treebank Part of Speech Tagger (Maximum entropy)
  [ ] moses_sample........ Moses Sample Models
  [ ] movie_reviews....... Sentiment Polarity Dataset Version 2.0
  [ ] names............... Names Corpus, Version 1.3 (1994-03-29)
  [ ] nombank.1.0......... NomBank Corpus 1.0
  [ ] nps_chat............ NPS Chat
  [ ] oanc_masc........... Open American National Corpus: Manually
                           Annotated Sub-Corpus
  [ ] omw................. Open Multilingual Wordnet
  [ ] paradigms........... Paradigm Corpus
  [ ] pe08................ Cross-Framework and Cross-Domain Parser
                           Evaluation Shared Task
  [ ] pil................. The Patient Information Leaflet (PIL) Corpus
  [ ] pl196x.............. Polish language of the XX century sixties
  [ ] ppattach............ Prepositional Phrase Attachment Corpus
  [ ] problem_reports..... Problem Report Corpus
  [ ] propbank............ Proposition Bank Corpus 1.0
  [ ] ptb................. Penn Treebank
Hit Enter to continue: l
  [*] punkt............... Punkt Tokenizer Models
  [ ] qc.................. Experimental Data for Question Classification
  [ ] reuters............. The Reuters-21578 benchmark corpus, ApteMod
                           version
  [ ] rslp................ RSLP Stemmer (Removedor de Sufixos da Lingua
                           Portuguesa)
  [ ] rte................. PASCAL RTE Challenges 1, 2, and 3
  [ ] sample_grammars..... Sample Grammars
  [ ] semcor.............. SemCor 3.0
  [ ] senseval............ SENSEVAL 2 Corpus: Sense Tagged Text
  [ ] sentiwordnet........ SentiWordNet
  [ ] shakespeare......... Shakespeare XML Corpus Sample
  [ ] sinica_treebank..... Sinica Treebank Corpus Sample
  [ ] smultron............ SMULTRON Corpus Sample
  [ ] snowball_data....... Snowball Data
  [ ] spanish_grammars.... Grammars for Spanish
  [ ] state_union......... C-Span State of the Union Address Corpus
  [ ] stopwords........... Stopwords Corpus
  [ ] swadesh............. Swadesh Wordlists
  [ ] switchboard......... Switchboard Corpus Sample
  [ ] tagsets............. Help on Tagsets
Hit Enter to continue: l
  [ ] timit............... TIMIT Corpus Sample
  [ ] toolbox............. Toolbox Sample Files
  [ ] treebank............ Penn Treebank Sample
  [ ] udhr2............... Universal Declaration of Human Rights Corpus
                           (Unicode Version)
  [ ] udhr................ Universal Declaration of Human Rights Corpus
  [ ] unicode_samples..... Unicode Samples
  [ ] universal_tagset.... Mappings to the Universal Part-of-Speech Tagset
  [ ] universal_treebanks_v20 Universal Treebanks Version 2.0
  [ ] verbnet............. VerbNet Lexicon, Version 2.1
  [ ] webtext............. Web Text Corpus
  [ ] wordnet............. WordNet
  [ ] wordnet_ic.......... WordNet-InfoContent
  [ ] words............... Word Lists
  [ ] ycoe................ York-Toronto-Helsinki Parsed Corpus of Old
                           English Prose

Collections:
  [ ] all-corpora......... All the corpora
  [P] all................. All packages
  [P] book................ Everything used in the NLTK Book

([*] marks installed packages; [P] marks partially installed collections)

---------------------------------------------------------------------------
    d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
---------------------------------------------------------------------------
Downloader> d

Download which package (l=list; x=cancel)?
  Identifier> maxent_treebank_pos_tagger
    Downloading package maxent_treebank_pos_tagger to
        /home/pi/nltk_data...
      Unzipping taggers/maxent_treebank_pos_tagger.zip.

---------------------------------------------------------------------------
    d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
---------------------------------------------------------------------------
Downloader> q
True

# 重新執行
>>> tagged = nltk.pos_tag(tokens)
>>> tagged[0:6]
[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')]
>>> 

 

 

 

 

W!o 的派生‧十日談之《九》

Xiaoyuncong_nvwa
清初蕭雲從《女媧

180px-Anonymous-Fuxi_and_Nüwa3
新疆岀土的人首蛇身伏羲女媧圖。其中女媧持規,伏羲持矩

女媧補天
女媧補天

淮南子‧覽冥

往古之時,四極廢,九州裂,天不兼複,地不周載。火爁焱而不滅,水浩洋而不息。猛獸食顓民,鷙鳥攫老弱。於是女媧鍊五色石以補蒼天,斷鼇足以立四極,殺黑龍以濟冀州,積蘆灰以止淫水。蒼天補,四極正,淫水涸,冀州平,狡蟲死,顓民生。

篆文媧 

篆文鬲

説文解字》:媧,古之神聖女,化萬物者也。从女,咼聲。篆文媧,籀文媧从篆文鬲

話說共工怒而觸不周之山,天柱摺,地維絕。天傾西北,故日月星辰移焉;地不滿西南,故水潦塵埃歸焉。或許此乃遠古之時『洪‧江』滔天之『大洪水』,傳自『洛水神龜』感念大禹之後。故而『女媧氏』以神『』煉『五色石』以『補天』當在大禹之前,此故得於『大荒山』『無稽崖』『青埂峰』之下無緣補天之『頑石』所記。當真是以『天子之劍』『制約』造化之『五行』,能開陰陽,持春夏,行秋冬,上決浮雲,下絕地紀。此劍一用,匡【正】諸侯,天下服矣的耶!!

誰能告訴我,為何故事總是起於『 Once Upon a Time 』,那個『很久很久以前』??

若說天下有多少種『派生』語言,《Python Implementations》︰

An “implementation” of Python should be taken to mean a program or environment which provides support for the execution of programs written in the Python language, as represented by the CPython reference implementation.

There have been and are several distinct software packages providing of what we all recognize as Python, although some of those are more like distributions or variants of some existing implementation than a completely new implementation of the language.

其中『 PyPy 』可就有趣的了,用『派生』寫『 Python 』,還能跑的『比較快』??

PyPy is a fast, compliant alternative implementation of the Python language (2.7.8 and 3.2.5). It has several advantages and distinct features:

  • Speed: thanks to its Just-in-Time compiler, Python programs often run faster on PyPy. (What is a JIT compiler?)

    “If you want your code to run faster, you should probably just use PyPy” — Guido van Rossum (creator of Python)

  • Memory usage: memory-hungry Python programs (several hundreds of MBs or more) might end up taking less space than they do in CPython.

  • Compatibility: PyPy is highly compatible with existing python code. It supports cffi and can run popular python libraries like twisted and django.

  • Sandboxing: PyPy provides the ability to run untrusted code in a fully secure way.

  • Stackless: PyPy comes by default with support for stackless mode, providing micro-threads for massive concurrency.

  • As well as other features.

要如何看待這些『建置』  implementation 的呢?也許好好『履行』 Implementation 其一,將自可及於『其它』,或若有『所思』,也可讀讀『淮南子』之《說林訓》︰

以一世之度制治天下,譬猶客之乘舟,中流遺其劍,遽契其舟桅,暮薄而求之,其不知物類亦甚矣!夫隨一隅之跡,而不知因天地以游,惑莫大焉。雖時有所合,然而不足貴也。譬若旱歲之土龍,疾疫之芻狗,是時為帝者也。曹氏之裂布,蛷者貴之,然非夏后氏之璜。無古無今,無始無終,未有天地而生天地,至深微廣大矣。足以蹍者淺矣,然待所不蹍而後行;智所知者偏矣,然待所不知而後明。遊者以足蹶,以手㧊,不得其數,愈蹶愈敗。及其能遊者,非手足者矣。鳥飛反鄉,兔走歸窟,狐死首丘,寒將翔水,各哀其所生。毋貽盲者鏡,毋予躄者履,毋賞越人章甫,非其用也。

椎固有柄,不能自椓;目見百步之外,不能自見其眥。狗彘不擇甂甌而食,偷肥其體而顧近其死。鳳皇高翔千仞之上,故莫之能致。月照天下,蝕于詹諸。騰蛇遊霧,而殆於蝍蛆。鳥力勝日,而服於鵻禮,能有修短也。莫壽於殤子,而彭祖為夭矣。短綆不可以汲深,器小不可以盛大,非其任也。怒出於不怒,為出於不為。視於無形,則得其所見矣;聽於無聲,則得其所聞矣。至味不慊,至言不文,至樂不笑,至音不叫,大匠不斫,大豆不具,大勇不鬥,得道而德從之矣。譬若黃鍾之比宮,太簇之比商,無更調焉。以瓦鉒者全,以金鉒者跋,以玉鉒者發,是故所重者在外,則內為之掘。逐獸者目不見太山,嗜欲在外,則明所蔽矣。聽有音之音者聾,聽無音之音者聰;不聾不聰,與神明通。

卜者操龜,筮者端策,以問于數,安所問之哉!舞者舉節,坐者不期而拌皆如一,所極同也。日出暘谷,入于虞淵,莫知其動,須臾之間,俛人之頸。人莫欲學御龍,而皆欲學御馬;莫欲學治鬼,而欲學治人。急所用也。解門以為薪,塞井以為臼,人之從事,或時相似,水火相憎,鏏在其間,五味以和。骨肉相愛,讒賊間之,而父子相危。夫所以養而害所養,譬猶削足而適履,殺頭而便冠。昌羊去蚤虱而來蚙窮,除小害而致大賊,欲小快而害大利。牆之壞也,不若無也,然逾屋之覆。璧瑗成器,礛諸之功;鏌邪斷割,砥礪之力。狡兔得而獵犬烹,高鳥盡而強弩藏。虻與驥,致千里而不飛,無糗糧之資而不饑。失火而遇雨,失火則不幸,遇雨則幸也。故禍中有福也。

鬻棺者,欲民之疾病也;畜粟者,欲歲之荒饑也。水靜則平,平則清,清則見物之形,弗能匿也。故可以為正。川竭而穀虛,丘夷而淵塞,唇竭而齒寒,河水之深,其壤在山。鈞之縞也,一端以為冠,一端以為袜,冠則戴致之,袜則蹍履之。知己者不可誘以物,明於死生者,不可卻以危。故善遊者不可懼以涉。親莫親於骨肉,節族之屬連也。心失其制,乃反自喜,況疏遠乎!聖人之一道,猶葵之與日也。雖不能與終始哉,其向之誠也。宮池涔則溢,旱則涸。江水之原,淵泉不能竭。蓋非橑不能蔽日,輪非輻不能追疾,然而橑輻未足恃也。金勝木者,非以一刃殘林也;土勝水者,非以一墣塞江也。躄者見虎而不走,非勇,勢不便也。傾者易覆也。倚者易軵也。幾易助也,濕易雨也。設鼠者機動,釣魚者泛杭,任動者車鳴也。

芻狗能立而不能行,蛇床似麋蕪而不能芳。謂許由無德,烏獲無力,莫不醜於色。人莫不奮於其所不足。以兔之走,使犬如馬,則逮日歸風;及其為馬,則又不能走矣。冬有雷電,夏有霜雪,然而寒暑之勢不易,小變不足以妨大節。黃帝生陰陽,上駢生耳目,桑林生臂手,此女媧所以七十化也。終日之言,必有聖之事;百發之中,必有羿、逢蒙之巧。然而世不與也,其守節非也。牛蹄彘顱亦骨也,而世弗灼,必問吉凶於龜者,以其曆歲久矣。近敖倉者,不為之多飯;臨江河者,不為之多飲;期滿腹而已。蘭芝以芳,未嘗見霜;鼓造辟兵,壽盡五月之望。舌之與齒,孰先砻也?錞之與刃,孰先弊也?繩之與矢,孰先直也?今鱔之與蛇,蠶之與蠋,狀相類而愛憎異。晉以垂棘之璧得虞、虢,驪戎以美女亡晉國。聾者不歌,無以自樂;盲者不觀,無以接物。觀射者遺其執,觀書者忘其愛。意有所在,則忘其所守。

……

 

然後大膽『解讀』《 TPG 》 Toy Parser Generator 『原始碼』,『遊藝』於『文法』『語意』物件之中,『採擷』 TPG 之『自生自成』的『精華』︰

Toy Parser Generator is a lexical and syntactic parser generator for Python. This generator was born from a simple statement: YACC is too complex to use in simple cases (calculators, configuration files, small programming languages, …).

TPG can very simply write parsers that are usefull for most every day needs (even if it can’t make your coffee). With a very clear and simple syntax, you can write an attributed grammar that is translated into a recursive descendant parser. TPG generated code is very closed to the original grammar. This means that the parser works like the grammar. A grammar rule can be seen as a method of the parser class, symbols as method calls, attributes as method parameters and semantic values as return values. You can also add Python code directly into grammar rules and build abstract syntax trees while parsing.

The first application of TPG is TPG itself. The first (not released) version of TPG has been written by hand then was used to generate next versions. Now TPG can generate itself.

For an uptodate documentation, please read tpg.pdf.

 

 

 

 

 

W!o 的派生‧十日談之《八》

U348P5058DT20141115014820
英國漢學家閔福德
歷時十二年之易經英譯

Xiantianbagua

Sun_Wen_Red_Chamber_14

紅樓夢‧大觀園

易經》第二十卦‧風地觀

:盥而不荐,有孚顒若。

彖曰:大觀在上,順而巽,中正以觀天下。觀,盥而不荐,有孚顒若,下觀而化也。 觀天之神道,而四時不忒, 聖人以神道設教,而天下服矣。

象曰:風行地上,觀﹔先王以省方,觀民設教。

初六:童觀,小人無咎,君子吝。
象曰:初六童觀,小人道也。

六二:窺觀,利女貞。
象曰:窺觀女貞,亦可丑也。

六三:觀我生,進退。
象曰:觀我生,進退﹔未失道也。

六四:觀國之光,利用賓于王。
象曰:觀國之光,尚賓也。

九五:觀我生,君子無咎。
象曰:觀我生,觀民也。

上九:觀其生,君子無咎。
象曰:觀其生,志未平也。

論語‧學而篇
子曰:不患人之不己知,患不知人也。

論語 ‧為政篇
子曰:視其所以,觀其所由,察其所安;人焉廋哉。人焉廋哉。 

若果】『一葉知秋』,履霜繼至堅冰,所以或有『深謀遠慮』,善採『先天下之憂而憂』之『舉措之旨』。所謂的『大觀在上』是說『自然人生法則』,『順而巽』是講『順應自然律』而且『深入其理』,這就是『』之大者!!

……

天地之《生》是一,《生生》故為多。所謂『數』始於一,然後二,然後三,然後很多很多。恰似古今中外,都有個『函三』『惟‧唯』一的說法︰

西︰ 聖父,聖子,聖靈

東︰ 太易、太初、太始

於是千百億年之後,『眾生』蔚為『大觀』,有人開始用『理性』之『眼』,欲觀宇宙『大霹靂』之『開天闢地』的『溫柔』。尋找元初的

立德,立功,立言

,卻是

不見其『德』,有『道』

難覓其『功』,成『果』

不知其『言』,現『象』

,當真『不識廬山真面目』的耶!

 

因此現今有人欲察『派生』之『博多』,當如何求『其一』的呢?『物』有『始』『中』『終』,或求『其始』的吧︰

東西』 Object 為本!

這個『阿堵物』彷彿可『比擬』於《易經》之 天地定位

昔者聖人之作易也,幽贊於神明而生蓍,參天兩地而倚數,觀變於陰陽而立卦,發揮於剛柔而生爻。和順於道德而理於義,窮理盡性以至於命。昔者聖人之作易也,將以順性命之理,是以立天之道曰陰與陽,立地之道曰柔與剛,立人之道曰仁與義,兼三才而兩之,故易六畫而成卦。分陰分陽,迭用柔剛,故易六位而成章。

天地定位,山澤通氣,雷風相薄,水火不相射,八卦相錯,數往者順,知來者逆,是故易逆數也。

雷以動之,風以散之,雨以潤之,日以烜之,艮以止之,兌以說之,乾以君之,坤以藏之。

追跡『八卦』之祖者乎??

pi@raspberrypi ~ $ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class 八卦(object):
...     def __init__(self):
...         self.祖="太極"
...         self.名="不能問"
...         self.義="不可說"
...     def 相對(self):
...         raise NameError("無法度")
... 
>>> 路人甲=八卦()
>>> 路人甲.祖
'太極'
>>> 路人甲.名
'不能問'
>>> 路人甲.義
'不可說'
>>> 路人甲.相對()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in 相對
NameError: 無法度

>>> class 乾(八卦):
...     def __init__(self):
...         super().__init__()
...         self.名="乾"
...         self.義="天"
...         self.象="☰"
...     def 相對(self):
...         return 坤
... 
>>> 天=乾()
>>> 天.祖
'太極'
>>> 天.名
'乾'
>>> 天.義
'天'
>>> 天.象
'☰'

>>> class 坤(八卦):
...     def __init__(self):
...         super().__init__()
...         self.名="坤"
...         self.義="地"
...         self.象="☷"
...     def 相對(self):
...         return 乾
... 
>>> 地=坤()
>>> 地.祖
'太極'
>>> 地.名
'坤'
>>> 地.義
'地'
>>> 地.象
'☷'
>>> 地.相對().名
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object '乾' has no attribute '名'
>>> 地.相對()().名
'乾'
>>> 地.相對()().義
'天'
>>> 地.相對()().象
'☰'

 

 

── 又誰管『點點點』… dot dot dot 是何意的呢?──

 

 

 

 

 

 

W!o 的派生‧十日談之《七》

5141wQKpnDL

cover

Dive Into Python 》 is a free Python book for experienced programmers.

It was originally hosted at DiveIntoPython.org, but the author has pulled down all copies. It is being mirrored here. You can read the book online, or download it in a variety of formats. It is also available in multiple languages.

我們讀書越多,就越發現我們是無知的。── 雪萊

Dive Into Python 3 》 covers Python 3 and its differences from Python 2. Compared to Dive Into Python, it’s about 20% revised and 80% new material. The book is now complete, but feedback is always welcome.

腹有詩書氣自華,讀書萬卷始通神。── 蘇軾

既是活在資訊爆炸的時代,怎麼可能缺乏知識的呢?這事頂不好說,借人家的話來講︰

蒲松齡‧《阿寶

異史氏曰︰『性癡則其志凝,故書癡者文必工,藝癡者技必良。世之落拓而無成者,皆自謂不癡者也。且如粉花蕩產,盧雉頃家,顧癡人事哉!以是知慧黠而過,乃是真癡,彼孫子何癡乎!』

密尔顿‧《论出版自由

因为书籍并不是绝对死的东西。它包藏着一种生命的潜力,和作者一样活跃。不仅如此,它还象一个宝瓶,把创作者活生生的智慧中最纯净的菁华保存起来。我知道它们是非常活跃的,而且繁殖力也是极强的,就象神话中的龙齿①一样。当它们被撒在各处以后,就可能长出武士来。但是,从另一方面来说,如果不特别小心的话,误杀好人和误禁好书就会同样容易。杀人只是杀死了一个理性的动物,破坏了一个上帝的象;而禁止好书则是扼杀了理性本身,破坏了瞳仁中的上帝圣象②。

也許『郭沫若』說的好︰

』是『』的,書是『』的。『』『』讀『』『』,可以把『』讀『』。『』『』讀『』『』,可以把『』讀『』。

 

如何『』 Python ?就從『』本『派生』的『』開始。因『』故及於它『』它『』,以至於『』而已!!

□︰ 難道都不用練習的嗎?

○︰此語未免太癡!《論語》

學而』篇開宗明義講︰『』而時『』之的吧!!

比方說《潜入派生》 Dive into Python 第二章第四節

《 2.4. Everything Is an Object 》講︰

2.4.2. What’s an Object?

Everything in Python is an object, and almost everything has attributes and methods. All functions have a built-in attribute __doc__, which returns the doc string defined in the function’s source code. The sys module is an object which has (among other things) an attribute called path. And so forth.

Still, this begs the question. What is an object? Different programming languages define “object” in different ways. In some, it means that all objects must have attributes and methods; in others, it means that all objects are subclassable. In Python, the definition is looser; some objects have neither attributes nor methods (more on this in Chapter 3), and not all objects are subclassable (more on this in Chapter 5). But everything is an object in the sense that it can be assigned to a variable or passed as an argument to a function (more in this in Chapter 4).

This is so important that I’m going to repeat it in case you missed it the first few times: everything in Python is an object. Strings are objects. Lists are objects. Functions are objects. Even modules are objects.

那麼我們將如何理解『在派生中,一切皆是物件。』這句話呢?要是不深入『派生』的『語法』以及『語意』,只依靠著『語用』根本是不足以『回答』的吧!而且不同的『程式語言』,『口號』不同,『哲學』也不一樣!!Python 號稱『多典範』,『程序』為主的寫作、『物件』中心之編程,『泛函式』概念的淺嚐,……等等,也許可以這麼說︰

『派生』支持的『作法』,讓它『語法』上『方便容易』。

『派生』不支持的『行事』,也可『己選自擇』的『表現』。

因此想要掌握 Python 語言,『深思』、『細慮』以及『多實驗』或許是個好的起步。就像嘗試看看,在『派生』中,什麼是『函式』 function 的呢?

 

pi@raspberrypi ~ $ python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# 列出『整數』物件有的『屬性』與『方法』
>>> dir(3)
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']


# 『泛函式』小試
>>> def 求值(函數,參數):
...     return 函數(參數)
... 

# 『函數』定義
>>> def f(x):
...     return x*x +2*x -1
... 

# 『函數』求值
>>> 求值(f,5)
34

# f 是『函數』物件的『標識符』
>>> f
<function f at 0x76a5cf60>

# 『函數』呼叫,是由『標識符』 f 與『參數元組』 (5) 所構成
>>> f (5)
34

# 『函數』的重要『屬性』是『可呼叫』 callable
>>> callable(f)
True

# 列出『函數』物件有的『屬性』與『方法』
>>> dir(f)
['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

# λ 『匿名函數』
>>> 求值(lambda x:x*x + 2*x -1,5)
34

>>> lambda x:x*x + 2*x -1
<function <lambda> at 0x76a5ced0>

>>> dir(lambda x:x*x + 2*x -1)
['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']

 

─── 豈是一句『可呼叫』 callable 了得!! ───

 

 

 

 

W!o 的派生‧十日談之《六》

615px-Tupper's_self_referential_formula_plot.svg

300px-MagrittePipe

220px-Droste

{1\over 2} < \left\lfloor \mathrm{mod}\left(\left\lfloor {y \over 17} \right\rfloor 2^{-17 \lfloor x \rfloor - \mathrm{mod}(\lfloor y\rfloor, 17)},2\right)\right\rfloor

二零零一年加拿大傑夫‧塔珀 Jeff Tupper 所發現的自指公式,它的二維『函數圖像』,與數學的『公式外觀』相仿。

一九二九年比利時畫家雷內‧弗朗索瓦‧吉蘭‧馬格利特 René François Ghislain Magritte  名作《形象的叛逆》The Treachery of Images 上用法文寫著 『你看到的不是煙斗』。

一九零四年荷蘭著名品牌德羅斯特 Droste 所販售的可可粉之包裝盒上的圖片是一位護士拿著一個上有杯子及紙盒的托盤,托盤裡的杯子和紙盒上之圖案也就是這張圖片。

不過『自我指涉』可能會產生『矛盾』,『遞迴』也許將陷入『無窮循環』,然而它們的『魅力』卻是歷久彌新!!

如果說『雷公』遇到『電母』 ── 就像『 Mr. & Mrs. Smith 』執行任務 ── ,那在『可以換頭』的倒數時刻,也許離『科學怪人』之出現不遠的吧。

磁鐵

看見磁力線

抽象』的概念雖然『無象』可以用來作『想象』,就如同前面談到過的『思想實驗』一樣,還是可以建造『情境』方便『觀相』的。假使說『思考』是根『概念磁鐵』,那麼『思維』就是『磁力線』。從『創造發想』的『發散處』出發,抵達『清晰自恰』之『收斂點』。因此『磁力線』的『封閉性』也可比喻成『思維』是『自我遞迴』的了。這樣或許『思考』在『』與『』的方面能夠成為『自行車』之『雙輪』,而這個『操控』之人也逐漸地步上了『收發自如』的道路。

我喃喃自語說︰我做了一個夢。在那夢中我做了一個夢,我喃喃自語說︰我做了一個夢。宛如我置身『鏡廊』一面『鏡子』前,我見着了『鏡裡』的我置身『鏡廊』一面『鏡子』前,… \infty

俄羅斯娃哇是『有趣的』事物,雖然只有『有限』的幾個『迭套』,它卻是『象徵』一個『不思議』的『奧秘』。其實『遞迴』Recursion 與『疊代』 Iteration 兩個概念,彼此間有著很深刻的『聯繫』。

View of the restored paintings of the Ha

俄羅斯娃哇

人類能夠『獨立思考』嗎?人們講︰因為他『如此說』,所以我『這般信』,難到這果是『合理』的嗎??還是這真的『不合裡』的呢???就像有人探討後認為︰『差異』在『關鍵處』!也在『對的人』!!於是『問題』變成了是否『相信』了『對的人』,且在『事物』之『關鍵處』着力,就『這樣』……『決定』了……是否從此以後都能過著『自主判斷』的日子的了!!!

220px-Louvre_identifiers_Ma1274-MR242

羅浮宮雕塑背後的標識符

一個『標識符』 ID identifier

能有多少好說之事,需要如是的陣仗?假使你已發現『身份證』比『你自己』更能『證明』你是誰!各種『號碼』效用之大,可以『轉帳購物』,你才剛知道『不變』 Immutable 之『物件』 object 要比『可變』 mutable 的『你』更『安全』『可靠』的哩!!不要『懷疑』,即使那些『號碼』因『你』而『有』,在『電腦語言』裡,他們可是『第一類公民』 First-class value ,享有第一等的『價值』??

雖然有時令人『千迴百轉』的想不通?是『機器』服務於『』,還是『』符合『機器』的『處理』?!

或許那個『鄭三絕』能讓人們『回回神』的吧!『鄭板橋』固因『詩書畫』稱『三絕』,他傳聞軼事『也絕』︰

『絕對』難能卻『對』,
『絕句』自可斷『句』,
『絕情』反倒多『情』。

鄭板橋‧竹

竹本【笨】虛心是我師

 

鄭板橋‧【一聯千金

龍虎山中真宰相

麒麟閣上活神仙

 

難得糊塗

難得糊塗

 

鄭縣令‧【崇仁‧大悲】寺‧庵之戀

硃筆一批

一半葫蘆一半瓢,合來一處好成桃;
徒令人定風歸寂,此後敲門月影遙:
鳥性悅時空即色,蓮花落處靜偏嬌;
是誰勾卻風流案,記取當年鄭板橋。

 

派生』 python 的『標識符』,2.X 的『版本』如

Python Basic Syntax 》教程裡所言︰

Python Identifiers:

Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).

Python does not allow punctuation characters such as @, and % within identifiers. Python is a case sensitive programming language. Thus, Manpower and manpower are two different identifiers in Python.</span>  <span style="color: #808080;">Here are following identifier <span style="color: #cc99ff;"><strong>naming convention</strong></span> for Python:</span>  <span style="color: #808080;">‧Class names start with an uppercase letter and all other identifiers with a lowercase letter.</span>  <span style="color: #808080;">‧Starting an identifier with a single leading underscore indicates by convention that the identifier is meant to be private.</span>  <span style="color: #808080;">‧Starting an identifier with two leading underscores indicates a strongly private identifier.</span>  <span style="color: #808080;">‧If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.</span>  然而從 Python 3.0 開始,『<strong>派生</strong>』已經支持『<strong><a href="https://docs.python.org/3/reference/lexical_analysis.html#identifiers">萬國碼</a></strong>』 Unicode 的『<strong>標識符</strong>』,這意味著︰ <pre class="lang:sh decode:true "># 可以使用中文『標識符』 >>> 甲=7 >>> 乙=甲*甲-3*甲+2 >>> 甲;乙 7 30 >>></pre> 。 <span style="color: #ff99cc;">『<strong>派生</strong>』之『<strong>標識符</strong>』是個『<strong>標籤</strong>』『<strong>索引</strong>』,『<strong>功用</strong>』在於『<strong>指稱</strong>』『<strong>標示</strong>』物件,不具有任何『型別』,以其所『<strong>綁定</strong>』 <span style="color: #cc99ff;"><strong><a href="http://stackoverflow.com/questions/9073995/difference-between-mutation-rebinding-copying-value-and-assignment-operator"><span style="color: #cc99ff;">binding</span></a></strong></span> 的『<strong>物件型別</strong>』為『<strong>型別</strong>』。也就是說,人們只是藉著『<strong>標識符</strong>』來操作其『<strong>所指</strong>』之『<strong>物件</strong>』。</span>  讀者可以嘗試用著  <span style="color: #808000;"><strong>id(...)</strong></span> <span style="color: #808000;"><strong> id(object) -> integer</strong></span>  <span style="color: #808000;"><span style="color: #ff9900;"><strong>Return the identity of an object.</strong> </span>This is guaranteed to be unique among simultaneously existing objects. (<span style="color: #cc99ff;">Hint: it's the object's memory address.</span>)</span>  ,了解所謂的『<span style="color: #cc99ff;"><strong>純標籤</strong></span>』之意︰ <pre class="lang:sh decode:true">pi@raspberrypi ~ python3
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

# 『標籤』自身沒有『型別』 type ,以『指稱』物件為『型別』
>>> x=5
>>> type(x);type(5)
<class ‘int’>
<class ‘int’>
>>>

# 『不可變』物件 id
>>> m=3
>>> id(m);id(3)
2965620
2965620
>>> n=m
>>> id(n);id(m);id(3)
2965620
2965620
2965620
>>> m=m-1
>>> id(m);id(n);id(2);id(3)
2965604
2965620
2965604
2965620
>>> m=m-1
>>> id(m);id(n);id(1);id(2);id(3)
2965588
2965620
2965588
2965604
2965620
>>>

『可變』物件 id
>>> l=[1,2,3]
>>> id(l);id([1,2,3])
1990071160
1990071840
>>> t=l
>>> t;id(t);l;id(l)
[1, 2, 3]
1990071160
[1, 2, 3]
1990071160
>>> l=l+[4]
>>> t;id(t);l;id(l)
[1, 2, 3]
1990071160
[1, 2, 3, 4]
1990073480

>>> l=[1,2,3]
>>> t=l
>>> l[0]=0
>>> t;id(t);l;id(l)
[0, 2, 3]
1990071840
[0, 2, 3]
1990071840
>>>