Python 的程式是寫在 .py 裡,
也就是說 .py 檔是 Python 的原始程式碼檔案
而 Python 會在執行 .py 檔時
將 .py 的程式碼編譯成中間程式碼檔 ( byte-compiled ) 的 .pyc 檔
以加快下次執行的速度。
所以當你執行一支 .py 檔時
Python 會先看看有沒有這支 .py 檔的 .pyc 檔
如果有而且 .py 檔的修改時間和 .pyc 檔一樣時
Python 就會讀 .pyc 檔
否則, Python 就會去讀原來的 .py 檔。
執行 .py 檔並不一定會產生出 .pyc 檔
通常是被來做 import 的 .py 檔才會產生出 .pyc 檔的。
將 Python 的 py 檔 Compile 成 pyc 檔
輸入 py_compile.py XXX.py
即可將 XXX.py 檔 Compile 成 XXX.pyc 檔
2011年9月21日 星期三
2011年9月16日 星期五
ifconfig command
$ ifconfig
lo0: flags=8049 mtu 16384
options=3
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010 mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863 mtu 1500
options=27
ether 00:25:4b:b9:f2:94
inet6 fe80::225:4bff:feb9:f294%en0 prefixlen 64 scopeid 0x4
inet 192.168.102.6 netmask 0xffffff00 broadcast 192.168.102.255
media: autoselect (100baseTX)
status: active
en1: flags=8863 mtu 1500
ether 00:25:00:41:f6:10
inet6 fe80::225:ff:fe41:f610%en1 prefixlen 64 scopeid 0x5
inet 192.168.105.109 netmask 0xffffff00 broadcast 192.168.105.255
media: autoselect
status: active
p2p0: flags=8843 mtu 2304
ether 02:25:00:41:f6:10
media: autoselect
status: inactive
lo0: flags=8049
options=3
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
gif0: flags=8010
stf0: flags=0<> mtu 1280
en0: flags=8863
options=27
ether 00:25:4b:b9:f2:94
inet6 fe80::225:4bff:feb9:f294%en0 prefixlen 64 scopeid 0x4
inet 192.168.102.6 netmask 0xffffff00 broadcast 192.168.102.255
media: autoselect (100baseTX
status: active
en1: flags=8863
ether 00:25:00:41:f6:10
inet6 fe80::225:ff:fe41:f610%en1 prefixlen 64 scopeid 0x5
inet 192.168.105.109 netmask 0xffffff00 broadcast 192.168.105.255
media: autoselect
status: active
p2p0: flags=8843
ether 02:25:00:41:f6:10
media: autoselect
status: inactive
2011年9月8日 星期四
2011年8月31日 星期三
Python Mayavi
可以下載學術版 http://www.enthought.com/products/edudownload.php
概念教學 http://www.fm0898.com/show.aspx?id=20103&cid=89
概念教學 http://www.fm0898.com/show.aspx?id=20103&cid=89
錯誤學習
錯誤學習
http://markmail.org/message/5revfv4wnzhh66rz
你的 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages 目录下有 tornado ?
我which PYTHON 确定我使用的python 是通过PORT安装的PYTHON
Pro:develop uer$ which python
/opt/local/bin/python
python的原身为:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
如果你直接在命令行执行 python 默认是执行的 /usr/bin/python
而 port 安装的 python 是 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6\
同理使用哪个版本安装的 setuptools 在使用 easy_install 的时候
也会把 package 安装到相应的 python 目录去
Mac Port 基本用法总结
1. Mac Port的下载地址
http://www.macports.org/install.php
2. Mac Port的说明文档
http://guide.macports.org/
3. Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/
为了提高安装速度,可以在安装新port时直接将此目录下的文件拷贝到新的Mac Port
相同的目录中就可以避免Port去网上下载。
4. 使用Mac Port前应该首先更新Port的index
$ sudo port selfupdate
Password:
Warning: port definitions are more than two weeks old, consider using selfupdate
—> Updating the ports tree
—> Updating MacPorts base sources using rsync
MacPorts base version 1.9.2 installed,
MacPorts base version 1.9.2 downloaded.
—> MacPorts base is already the latest version
The ports tree has been updated. To upgrade your installed ports, you should run
port upgrade outdated
5. 查看Mac Port中当前可用的软件包及其版本
$ port list
rabbitmq-server @2.4.0 net/rabbitmq-server
AppHack @1.1 aqua/AppHack
AppKiDo @0.985 aqua/AppKiDo
AquaLess @1.6 aqua/AquaLess
ArpSpyX @1.1 aqua/ArpSpyX
AssignmentTrackerX @2.0beta3.1 aqua/AssignmentTrackerX
BigSQL @1.0 aqua/BigSQL
BiggerSQL @1.3.9 aqua/BiggerSQL
Books @3.2.5c aqua/Books
……
4. 在Mac Port如何搜索需要安装的软件包?
$ port search maven
maven @1.0.2 (java, devel)
A java-based build and project management environment.
maven-ant-tasks @2.0.10 (devel, java)
Use many of Maven’s artifact handling features from Ant.
maven2 @2.2.1 (java, devel)
A java-based build and project management environment.
maven3 @3.0.3 (java, devel)
A java-based build and project management environment.
maven_select @0.3 (sysutils)
Switch the default Maven java build tool
Found 5 ports.
5. 搜索到需要安装的软件包之后,如何查看具体的软件包的内容和说明?
$ port info maven2
maven2 @2.2.1, Revision 3 (java, devel)
Description: Maven is a Java project management and project comprehension tool. Maven is based on the concept of a
project object model (POM) in that all the artifacts produced by Maven are a result of consulting a
well defined model for your project.Builds, documentation, source metrics, and source cross-references
are all controlled by your POM. Maven 2.0 is a complete rewrite of Maven 1.0 and as such is better
organized, faster and easier to use.
Homepage: http://maven.apache.org/
Build Dependencies: kaffe
Library Dependencies: maven_select
Platforms: darwin
License: unknown
Maintainers: blair@macports.org, gk5885@kickstyle.net
6. 查看即将安装的或者已经安装的软件包的依赖关系
$ port deps maven2
Full Name: maven2 @2.2.1_3
Build Dependencies: kaffe
Library Dependencies: maven_select
7. 查看安装时允许客户定制的参数
$ port variants maven2
maven2 has no variants
8. 查看了软件包的内容和说明,并确认确实要安装,则
$ sudo port install maven2
9. 安装完毕之后,清除安装时产生的临时文件
$ sudo port clean –all maven2
—> Cleaning maven2
10. 卸载已经用Mac Port安装的软件
sudo port uninstall maven2
http://markmail.org/message/5revfv4wnzhh66rz
你的 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages 目录下有 tornado ?
我which PYTHON 确定我使用的python 是通过PORT安装的PYTHON
Pro:develop uer$ which python
/opt/local/bin/python
python的原身为:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
如果你直接在命令行执行 python 默认是执行的 /usr/bin/python
而 port 安装的 python 是 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6\
同理使用哪个版本安装的 setuptools 在使用 easy_install 的时候
也会把 package 安装到相应的 python 目录去
Mac Port 基本用法总结
1. Mac Port的下载地址
http://www.macports.org/install.php
2. Mac Port的说明文档
http://guide.macports.org/
3. Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/
为了提高安装速度,可以在安装新port时直接将此目录下的文件拷贝到新的Mac Port
相同的目录中就可以避免Port去网上下载。
4. 使用Mac Port前应该首先更新Port的index
$ sudo port selfupdate
Password:
Warning: port definitions are more than two weeks old, consider using selfupdate
—> Updating the ports tree
—> Updating MacPorts base sources using rsync
MacPorts base version 1.9.2 installed,
MacPorts base version 1.9.2 downloaded.
—> MacPorts base is already the latest version
The ports tree has been updated. To upgrade your installed ports, you should run
port upgrade outdated
5. 查看Mac Port中当前可用的软件包及其版本
$ port list
rabbitmq-server @2.4.0 net/rabbitmq-server
AppHack @1.1 aqua/AppHack
AppKiDo @0.985 aqua/AppKiDo
AquaLess @1.6 aqua/AquaLess
ArpSpyX @1.1 aqua/ArpSpyX
AssignmentTrackerX @2.0beta3.1 aqua/AssignmentTrackerX
BigSQL @1.0 aqua/BigSQL
BiggerSQL @1.3.9 aqua/BiggerSQL
Books @3.2.5c aqua/Books
……
4. 在Mac Port如何搜索需要安装的软件包?
$ port search maven
maven @1.0.2 (java, devel)
A java-based build and project management environment.
maven-ant-tasks @2.0.10 (devel, java)
Use many of Maven’s artifact handling features from Ant.
maven2 @2.2.1 (java, devel)
A java-based build and project management environment.
maven3 @3.0.3 (java, devel)
A java-based build and project management environment.
maven_select @0.3 (sysutils)
Switch the default Maven java build tool
Found 5 ports.
5. 搜索到需要安装的软件包之后,如何查看具体的软件包的内容和说明?
$ port info maven2
maven2 @2.2.1, Revision 3 (java, devel)
Description: Maven is a Java project management and project comprehension tool. Maven is based on the concept of a
project object model (POM) in that all the artifacts produced by Maven are a result of consulting a
well defined model for your project.Builds, documentation, source metrics, and source cross-references
are all controlled by your POM. Maven 2.0 is a complete rewrite of Maven 1.0 and as such is better
organized, faster and easier to use.
Homepage: http://maven.apache.org/
Build Dependencies: kaffe
Library Dependencies: maven_select
Platforms: darwin
License: unknown
Maintainers: blair@macports.org, gk5885@kickstyle.net
6. 查看即将安装的或者已经安装的软件包的依赖关系
$ port deps maven2
Full Name: maven2 @2.2.1_3
Build Dependencies: kaffe
Library Dependencies: maven_select
7. 查看安装时允许客户定制的参数
$ port variants maven2
maven2 has no variants
8. 查看了软件包的内容和说明,并确认确实要安装,则
$ sudo port install maven2
9. 安装完毕之后,清除安装时产生的临时文件
$ sudo port clean –all maven2
—> Cleaning maven2
10. 卸载已经用Mac Port安装的软件
sudo port uninstall maven2
2011年8月29日 星期一
2011年8月24日 星期三
Mac path
http://www.python-forum.org/pythonforum/viewtopic.php?f=3&p=54429
/etc/profile -- applies to all users for all shells
~/.profile -- applies to just your account for all shells
~/.bash_profile -- applies to just your account for just the bash shell
在Mac OS X 10.6(Snow Leopard)中设置PATH 環境變數
sudo vim /etc/paths 將路徑添加到里面去
Python
Link1
Link2
$ which python
/usr/bin/python
If this is part of ~/.bash_profile, this will append the Python path on each startup.
PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}"
export PATH
This will append the Python directory to the path.
ps. Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/
/etc/profile -- applies to all users for all shells
~/.profile -- applies to just your account for all shells
~/.bash_profile -- applies to just your account for just the bash shell
在Mac OS X 10.6(Snow Leopard)中设置PATH 環境變數
sudo vim /etc/paths 將路徑添加到里面去
Python
Link1
Link2
$ which python
/usr/bin/python
If this is part of ~/.bash_profile, this will append the Python path on each startup.
PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}"
export PATH
This will append the Python directory to the path.
ps. Mac Port中第三方软件下载包存放的默认路径是:/opt/local/var/macports/distfiles/
訂閱:
文章 (Atom)