tool to create regular expression for you Wednesday, December 30, 2009



http://www.txt2re.com/

It's a online tool, you follow the three steps to create a regular expression easily

Python 如何在sys.path下包含自定义的路径 Wednesday, December 16, 2009





1〉定义环境变量PYTHONPATH,如果有多个路径则需要分号分隔,比如 PYTHONPATH=D:\_python;n:\_python1
2〉如果在d:\_python下还有子文件夹pyext,包含test.py。在d:\_python创建一个__init__.py写入import pyext,在pyext中也创建__init__.py(空文件)。 运行时使用import pyext.test就可以使用test.py

很有帮助的函数,可以显示api的信息 Thursday, December 10, 2009



"""Cheap and simple API helper

This program is part of "Dive Into Python", a free Python book for
experienced programmers. Visit http://diveintopython.org/ for the
latest version.
"""

__author__ = "Mark Pilgrim (mark@diveintopython.org)"
__version__ = "$Revision: 1.3 $"
__date__ = "$Date: 2004/05/05 21:57:19 $"
__copyright__ = "Copyright (c) 2001 Mark Pilgrim"
__license__ = "Python"

# While this is a good example script to teach about introspection,
# in real life it has been superceded by PyDoc, which is part of the
# standard library in Python 2.1 and later.
#
# Your IDE may already import the "help" function from pydoc
# automatically on startup; if not, do this:
#
# >>> from pydoc import help
#
# The help function in this module takes the object itself to get
# help on, but PyDoc can also take a string, like this:
#
# >>> help("string") # gets help on the string module
# >>> help("apihelper.help") # gets help on the function below
# >>> help() # enters an interactive help mode
#
# PyDoc can also act as an HTTP server to dynamically produce
# HTML-formatted documentation of any module in your path.
# That's wicked cool. Read more about PyDoc here:
# http://www.onlamp.com/pub/a/python/2001/04/18/pydoc.html

def info(object, spacing=10, collapse=1):
"""Print methods and doc strings.

Takes module, class, list, dictionary, or string."""
methodList = [e for e in dir(object) if callable(getattr(object, e))]
processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
print "\n".join(["[%s] %s" %
(method.ljust(spacing),
processFunc(str(getattr(object, method).__doc__)))
for method in methodList])

if __name__ == "__main__":
print help.__doc__

S60上使用python Wednesday, December 9, 2009



我在window xp上用S60 5th Edition SDK。
1> 首先需要下在两个软件

PythonForS60_1.9.7_Setup.exe
Python_1.9.7_3rdFP2_SDK_with_OpenC.zip

2> 在pc上安装PythonForS60_1.9.7_Setup.exe

这个软件中包含如下的sis包
pips.sisx
PythonScriptShell_1.9.7_3_0.sis
PythonScriptShell_1.9.7_3_2.sis
PythonScriptShell_1.9.7_high_capas.sis
PythonScriptShell_1.9.7_unsigned_devcert.sis
Python_1.9.7.sis
scribble_v0_2_0.sis
ssl_nokia_1_5_7.SIS
stdioserver_nokia_1_5_1_SS.sis

3> 我手机上安装了其中的两个:

Python_1.9.7.sis
PythonScriptShell_1.9.7_3_2.sis
这样你就可以在手机上运行python脚本了。sis包安装后有一些demo的脚本,正好可以体验一下。

4> 在pc上配置模拟器环境

解压Python_1.9.7_3rdFP2_SDK_with_OpenC.zip,然后把其中的文件导入到epoc32。我只拷贝了原来epoc32中没有的文件,已经有的文件没有覆盖。
可以自己写个脚本解决。如果需要的话可以联系我。

script to make python syntax hightlight in ultraedit Tuesday, December 8, 2009



/L10"Python" Line Comment = # Block Comment One = """ Block Comment Off = """ Escape Char = \ File Extensions = PY PYW
/Indent Strings = ":"
/Function String 1 = "%[ ,^t]++def[ ]+^([a-zA-Z0-9_]+*^):"
/Function String 2 = "%[ ,^t]++^(##[ a-zA-Z0-9_]+*^)##"
/Function String 3 = "%[ ,^t]++^(class[ ]+[a-zA-Z0-9_]+*^):"
/Delimiters = []{}()<>="''.,:+
/C1"Reserved Words"
and assert
break
class continue
def del
elif else except exec
finally for from
global
if import in is
lambda
map
not
None
or
pass print
raise range return
try
while
/C2"Built-in Functions"
abs apply
callable chr cmp coerce compile complex
delattr dir divmod
eval execfile
filter float
getattr globals
hasattr hash hex
id input int intern isinstance issubclass
joinfields
len list local long
max min match
oct open ord
pow
raw_input reduce reload repr round
search setattr setdefault slice str splitfields
unichr unicode
tuple type
vars
xrange
zip
__import__
/C3"__Methods__"
__abs__ __add__ __and__
__call__ __cmp__ __coerce__
__del__ __delattr__ __delitem__ __delslice__ __div__ __divmod__
__float__
__getattr__ __getitem__ __getslice__
__hash__ __hex__
__iadd__ __isub__ __imod__ __idiv__ __ipow__ __iand__ __ior__ __ixor__
__ilshift__ __irshift__
__invert__ __int__ __init__
__len__ __long__ __lshift__
__mod__ __mul__
__neg__ __nonzero__
__oct__ __or__
__pos__ __pow__
__radd__ __rdiv__ __rdivmod__ __rmod__ __rpow__ __rlshift__ __rrshift__
__rshift__ __rsub__ __rmul__ __repr__
__rand__ __rxor__ __ror__
__setattr__ __setitem__ __setslice__ __str__ __sub__
__xor__
/C4"__Attributes__"
__bases__
__class__
__dict__ __doc__
__methods__ __members__
__name__
__version__
/C5"Exceptions"
ArithmeticError AssertionError AttributeError
EOFError Exception
FloatingPointError
IOError ImportError IndentationError IndexError
KeyError KeyboardInterrupt
LookupError
MemoryError
NameError
OverflowError
RuntimeError
StandardError SyntaxError SystemError SystemExit
TabError TypeError
ValueError
ZeroDivisionError
/C6"Operators"
+=
-=
%=
/=
**=
&=
|=
^=
>>=
<<=
/C7"Common Libs"
AST atexit
BaseHTTPServer Bastion
cmd codecs commands compileall copy
CGIHTTPServer Complex
dbhash dircmp dis dospath dumbdbm
emacs
find fmt fnmatch ftplib
getopt glob gopherlib grep
htmllib httplib
ihooks imghdr imputil
linecache lockfile
macpath macurl2path mailbox mailcap
mimetools mimify mutex math
Mimewriter
newdir ni nntplib ntpath nturl2path
os ospath
pdb pickle pipes poly popen2 posixfile posixpath profile pstats pyclbr
pyexpat
Para
quopri
Queue
rand random regex regsub rfc822
sched sgmllib shelve site sndhdr string sys snmp
SimpleHTTPServer StringIO SocketServer
tb tempfile toaiff token tokenize traceback tty types tzparse
Tkinter
unicodedata urllib urlparse util uu
UserDict UserList
wave webbrowser whatsound whichdb whrandom
xdrlib xml xmlpackage
zmod
/C8"Others"
array
AzIM
Desc
fnmatch
Info
Run
struct self
StartKey StopKey