1.身体配合口诀:
蛙泳配合需注意,腿臂呼吸要适宜;
两臂划水腿放松,收手同时要收腿;
两臂前伸腿蹬水,臂腿伸直划一会;
划水头部慢抬起,伸手滑行慢呼气。
2.蛙泳手臂动作口诀:
蛙泳手臂对称划,桃型划水向侧下;
两手屈腕来抓水,屈臂高肘向后划;
划到肩下快收手,两肘用力向里夹;
双手平行向前伸,伸直放松往前进。
3.蛙泳腿部动作口诀:
蛙泳蹬腿像青蛙,向后蹬夹向前滑;
收腿脚跟臀边靠,两膝相距似肩宽;
边收边分慢收腿,翻脚脚尖向两边;
用力向后蹬夹水,两脚并拢漂一会。
Sunday, March 20, 2011
Monday, March 14, 2011
text formatter
#!/usr/bin/env python
# -*- coding: utf8 -*-
#-------------------------------------------------------------------------
#File name : strip.py
#Author : lfchen (Full Name please)
#Created : Mon 14 Mar 2011 02:04:35 PM CST
#Description :
# :
#Notes :
#-------------------------------------------------------------------------
#Copyright 2011 (c)
#-------------------------------------------------------------------------
import sys
import re
coding = 'utf-8'
def strip(infile, outfile):
try:
INFILE = open(infile,"r")
except:
print "\tERROR: fail to open file %s for processing" % infile
return
OUTFILE = open(outfile,"w")
prev_line=""
for line in INFILE:
line=line.decode(coding).rstrip("\n")
if line.endswith(" "): #keep ending space to avoid unintended contatenation of strings
line=line.rstrip() + " "
else:
line=line.rstrip()
if re.match(r'^\s*$', line) \
or line.endswith(".") or line.endswith("!") or line.endswith("?") or line.endswith(":") or line.endswith(";") \
or line.endswith("。".decode(coding)) or line.endswith("!".decode(coding)) or line.endswith("?".decode(coding)) \
or line.endswith(":".decode(coding)) or line.endswith(";".decode(coding)):
line += "\n"
if ('A'<=line[0]<='Z' or u'A'<=line[0]<=u'Z') and not prev_line.endswith("\n"):
line = "\n" + line
OUTFILE.write(line.encode(coding))
prev_line=line
INFILE.close()
OUTFILE.close()
if __name__ == "__main__":
if ("-h" in sys.argv[:]):
print "Usage: %s <filename(s)>" % sys.argv[0]
sys.exit(0)
else:
for filename in sys.argv[1:]:
print "dealing with file %s" % filename
strip(filename, "formatted_"+filename)
# -*- coding: utf8 -*-
#-------------------------------------------------------------------------
#File name : strip.py
#Author : lfchen (Full Name please)
#Created : Mon 14 Mar 2011 02:04:35 PM CST
#Description :
# :
#Notes :
#-------------------------------------------------------------------------
#Copyright 2011 (c)
#-------------------------------------------------------------------------
import sys
import re
coding = 'utf-8'
def strip(infile, outfile):
try:
INFILE = open(infile,"r")
except:
print "\tERROR: fail to open file %s for processing" % infile
return
OUTFILE = open(outfile,"w")
prev_line=""
for line in INFILE:
line=line.decode(coding).rstrip("\n")
if line.endswith(" "): #keep ending space to avoid unintended contatenation of strings
line=line.rstrip() + " "
else:
line=line.rstrip()
if re.match(r'^\s*$', line) \
or line.endswith(".") or line.endswith("!") or line.endswith("?") or line.endswith(":") or line.endswith(";") \
or line.endswith("。".decode(coding)) or line.endswith("!".decode(coding)) or line.endswith("?".decode(coding)) \
or line.endswith(":".decode(coding)) or line.endswith(";".decode(coding)):
line += "\n"
if ('A'<=line[0]<='Z' or u'A'<=line[0]<=u'Z') and not prev_line.endswith("\n"):
line = "\n" + line
OUTFILE.write(line.encode(coding))
prev_line=line
INFILE.close()
OUTFILE.close()
if __name__ == "__main__":
if ("-h" in sys.argv[:]):
print "Usage: %s <filename(s)>" % sys.argv[0]
sys.exit(0)
else:
for filename in sys.argv[1:]:
print "dealing with file %s" % filename
strip(filename, "formatted_"+filename)
Wednesday, March 9, 2011
steps to setup web server (wsgi based)
========== installing apache ==========
1. download httpd-x.x.xx.tar.gz, and extract to specified folder; rename if necessary
2. chdir to exacted folder
3. ./configure --prefix=$PREFIX ($PWD is supported)
4. make (compile)
5. make install (install)
6. ./httpd -k start|stop|restart
========== installing python ==========
1. basically the same as apache installation
2. additional package (try easy_install) including genshi, repoze.tm, zif.sedna, xlwt, verilib, mx, RuleDispatch)0.
http://peak.telecommunity.com/snapshots/PyProtocols-1.0a0dev-r2302.tar.gz
http://peak.telecommunity.com/snapshots/RuleDispatch-0.5a1.dev-r2618.tar.gz
========== TurboGears ========
0. what's TurboGears
connect python to web (web io, db)
1. to install
download: wget http://www.turbogears.org/download/tgsetup.py
install: python tgsetup.py
========== paste ========
0. what's paste
1. to install (requires setuptools)
download: wget http://pypi.python.org/packages/source/P/Paste/Paste-1.7.5.1.tar.gz
wget http://pypi.python.org/packages/source/P/PasteScript/PasteScript-1.7.3.tar.gz#md5=9101a3a23809d3413b39ba8b75dd0bce
install: python setup.py install
========== pylons ========
0. what's pylons
Pylons combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility — but only if you need it. Out of the box, Pylons aims to make web development fast, flexible and easy.
1. to install
easy_install -f http://pylonshq.com/download/ Pylons==0.9.6.2
========== wsgi ========
0. what's wsgi
WSGI is the Web Server Gateway Interface. It is a specification for web servers and application servers to communicate with web applications (though it can also be used for more than that). It is a Python standard, described in detail in PEP 333.
1. to install
download: wget http://...
install: configure/make/make install
2. to use it, need python:paste & paste script
========== sedna ==========
1. download binary from website
http://modis.ispras.ru/sedna/install.html#srcfull
2. sh ./sedna-xxx-bin-xxx.sh
set the target addr to: /opt/soft/sedna-3.1.17 (3.4.66 doesn't work yet :( )
and the installed path will be .../sedna/
3. configure the result data folder (if necessary)
SEDNA_PATH/etc/sednaconf.xml
/opt/soft/SEDNA_DB_DATA
need to crate the data folder manually
4. at engsrv35, use se_exp export $mydb to export existent db
at bjdb, use se_exp import $mydb to import db
1. download httpd-x.x.xx.tar.gz, and extract to specified folder; rename if necessary
2. chdir to exacted folder
3. ./configure --prefix=$PREFIX ($PWD is supported)
4. make (compile)
5. make install (install)
6. ./httpd -k start|stop|restart
========== installing python ==========
1. basically the same as apache installation
2. additional package (try easy_install
http://peak.telecommunity.com/snapshots/PyProtocols-1.0a0dev-r2302.tar.gz
http://peak.telecommunity.com/snapshots/RuleDispatch-0.5a1.dev-r2618.tar.gz
========== TurboGears ========
0. what's TurboGears
connect python to web (web io, db)
1. to install
download: wget http://www.turbogears.org/download/tgsetup.py
install: python tgsetup.py
========== paste ========
0. what's paste
1. to install (requires setuptools)
download: wget http://pypi.python.org/packages/source/P/Paste/Paste-1.7.5.1.tar.gz
wget http://pypi.python.org/packages/source/P/PasteScript/PasteScript-1.7.3.tar.gz#md5=9101a3a23809d3413b39ba8b75dd0bce
install: python setup.py install
========== pylons ========
0. what's pylons
Pylons combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility — but only if you need it. Out of the box, Pylons aims to make web development fast, flexible and easy.
1. to install
easy_install -f http://pylonshq.com/download/ Pylons==0.9.6.2
========== wsgi ========
0. what's wsgi
WSGI is the Web Server Gateway Interface. It is a specification for web servers and application servers to communicate with web applications (though it can also be used for more than that). It is a Python standard, described in detail in PEP 333.
1. to install
download: wget http://...
install: configure/make/make install
2. to use it, need python:paste & paste script
========== sedna ==========
1. download binary from website
http://modis.ispras.ru/sedna/install.html#srcfull
2. sh ./sedna-xxx-bin-xxx.sh
set the target addr to: /opt/soft/sedna-3.1.17 (3.4.66 doesn't work yet :( )
and the installed path will be .../sedna/
3. configure the result data folder (if necessary)
SEDNA_PATH/etc/sednaconf.xml
need to crate the data folder manually
4. at engsrv35, use se_exp export $mydb
at bjdb, use se_exp import $mydb
Monday, March 7, 2011
decorator
Definition
A decorator is a function whose primary purpose is to wrap another function or class.
Purpose
The primary purpose of this wrapping is to transparently alter or enhance the behavior
of the object being wrapped.
Basic usage
Syntactically, decorators are denoted using the special @ symbol as follows. More than one decorator can also be applied.
@trace1
@trace0
def square(x):
return x*x
The preceding code is shorthand for the following:
def square(x):
return x*x
square = trace1(trace0(square))
Using parameters
A decorator can also accept arguments. Here’s an example:
@eventhandler('BUTTON')
def handle_button(msg):
...
The semantics of the decorator are as follows:
def handle_button(msg):
...
temp = eventhandler('BUTTON') # Call decorator with supplied arguments
handle_button = temp(handle_button) # Call the function returned by the decorator
Class decorator
Decorators can also be applied to class definitions. For example:
@foo
class Bar(object):
def __init__(self,x):
self.x = x
def spam(self):
statements
For class decorators, you should always have the decorator function return a class object
as a result.
A decorator is a function whose primary purpose is to wrap another function or class.
Purpose
The primary purpose of this wrapping is to transparently alter or enhance the behavior
of the object being wrapped.
Basic usage
Syntactically, decorators are denoted using the special @ symbol as follows. More than one decorator can also be applied.
@trace1
@trace0
def square(x):
return x*x
The preceding code is shorthand for the following:
def square(x):
return x*x
square = trace1(trace0(square))
Using parameters
A decorator can also accept arguments. Here’s an example:
@eventhandler('BUTTON')
def handle_button(msg):
...
The semantics of the decorator are as follows:
def handle_button(msg):
...
temp = eventhandler('BUTTON') # Call decorator with supplied arguments
handle_button = temp(handle_button) # Call the function returned by the decorator
Class decorator
Decorators can also be applied to class definitions. For example:
@foo
class Bar(object):
def __init__(self,x):
self.x = x
def spam(self):
statements
For class decorators, you should always have the decorator function return a class object
as a result.
how to release python program/lib
To distribute Python programs to others, you should use the distutils module.
1. As preparation, you should first cleanly organize your work into a directory that has a
README file, supporting documentation, and your source code.
Typically, this directory will contain a mix of library modules, packages, and scripts. Modules and packages refer to source files that will be loaded with import statements. Scripts are programs that will run as the main program to the interpreter (e.g., running as python scriptname).
Here is an example of a directory containing Python code:
spam/
README.txt
Documentation.txt
libspam.py # A single library module
spampkg/ # A package of support modules
__init__.py
foo.py
bar.py
runspam.py # A script to run as: python runspam.py
2. After you have organized your code, create a file setup.py in the top most directo-
ry (spam in the previous examples). In this file, put the following code:
# setup.py
from distutils.core import setup
setup(name = "spam",
version = "1.0",
py_modules = ['libspam'],
packages = ['spampkg'],
scripts = ['runspam.py'],
)
3.Type the following shell command to make a source distribution:
% python setup.py sdist
...
This creates an archive file such as spam-1.0.tar.gz or spam-1.0.zip in the directo-
ry spam/dist.
If you type 'python setup.py bdist', a binary distribution is created in
which all of the .py files have already been precompiled into .pyc files and placed into
a directory structure that mimics that of the local platform.
If you run 'python setup.py bdist_wininst' on a Windows machine, an .exe file will be created.
4. To install, a user simply unpacks the archive and performs these steps:
% unzip spam-1.0.zip
...
% cd spam-1.0
% python setup.py install
This installs the software into the local Python distribution and makes it available for
general use. Modules and packages are normally installed into a directory called
"site-packages" in the Python library.
5. alternative install option
Python software is often distributed in the form of an .egg file.This format is created by the popular setuptools
extension (http://pypi.python.org/pypi/setuptools).To support setuptools, you can
simply change the first part of your setup.py file as follows:
# setup.py
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name = "spam",
...
)
6. Appendix:
list of setup arguments:
Parameters to setup()Parameter Description
name Name of the package (required)
version Version number (required)
author Author’s name
author_email Author’s email address
maintainer Maintainer’s name
maintainer_email Maintainer’s email
url Home page for the package
description Short description of the package
long_description Long description of the package
download_url Location where package can be downloaded
classifiers List of string classifiers
1. As preparation, you should first cleanly organize your work into a directory that has a
README file, supporting documentation, and your source code.
Typically, this directory will contain a mix of library modules, packages, and scripts. Modules and packages refer to source files that will be loaded with import statements. Scripts are programs that will run as the main program to the interpreter (e.g., running as python scriptname).
Here is an example of a directory containing Python code:
spam/
README.txt
Documentation.txt
libspam.py # A single library module
spampkg/ # A package of support modules
__init__.py
foo.py
bar.py
runspam.py # A script to run as: python runspam.py
2. After you have organized your code, create a file setup.py in the top most directo-
ry (spam in the previous examples). In this file, put the following code:
# setup.py
from distutils.core import setup
setup(name = "spam",
version = "1.0",
py_modules = ['libspam'],
packages = ['spampkg'],
scripts = ['runspam.py'],
)
3.Type the following shell command to make a source distribution:
% python setup.py sdist
...
This creates an archive file such as spam-1.0.tar.gz or spam-1.0.zip in the directo-
ry spam/dist.
If you type 'python setup.py bdist', a binary distribution is created in
which all of the .py files have already been precompiled into .pyc files and placed into
a directory structure that mimics that of the local platform.
If you run 'python setup.py bdist_wininst' on a Windows machine, an .exe file will be created.
4. To install, a user simply unpacks the archive and performs these steps:
% unzip spam-1.0.zip
...
% cd spam-1.0
% python setup.py install
This installs the software into the local Python distribution and makes it available for
general use. Modules and packages are normally installed into a directory called
"site-packages" in the Python library.
5. alternative install option
Python software is often distributed in the form of an .egg file.This format is created by the popular setuptools
extension (http://pypi.python.org/pypi/setuptools).To support setuptools, you can
simply change the first part of your setup.py file as follows:
# setup.py
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name = "spam",
...
)
6. Appendix:
list of setup arguments:
Parameters to setup()Parameter Description
name Name of the package (required)
version Version number (required)
author Author’s name
author_email Author’s email address
maintainer Maintainer’s name
maintainer_email Maintainer’s email
url Home page for the package
description Short description of the package
long_description Long description of the package
download_url Location where package can be downloaded
classifiers List of string classifiers
Sunday, March 6, 2011
游泳学习
踩水
保持双大腿在前,两脚呈摇橹状
1. 小臂平面向后划
2. 小腿收回状态时,脚往外侧翻,指向蹬出方向
3. 蹬出双腿
4. 收回。过程中双脚垂直于收回方向
蛙泳 - 简单分为5步:
划(臂)/收(臂)/伸(臂)、蹬(腿)/漂
1. 划臂至与肩同宽时,向下压水,使头部浮出水面。
2. 收臂至胸前
3. 先伸臂,然后向侧后方蹬腿。蹬腿前,把脚掌向外翻,以增加划水面积。
4. 直体漂滑
自由泳 -
保持双大腿在前,两脚呈摇橹状
1. 小臂平面向后划
2. 小腿收回状态时,脚往外侧翻,指向蹬出方向
3. 蹬出双腿
4. 收回。过程中双脚垂直于收回方向
蛙泳 - 简单分为5步:
划(臂)/收(臂)/伸(臂)、蹬(腿)/漂
1. 划臂至与肩同宽时,向下压水,使头部浮出水面。
2. 收臂至胸前
3. 先伸臂,然后向侧后方蹬腿。蹬腿前,把脚掌向外翻,以增加划水面积。
4. 直体漂滑
自由泳 -
Subscribe to:
Posts (Atom)