随笔分类 -  Python

py2exe 转换 pytetris
摘要:首先,需要一个给 py2exe 使用的 python 脚本,我命名为 setup.py,内容如下:1fromdistutils.coreimportsetup2importglob,shutil3importpy2exe4setup(windows=["main.py"])5shutil.copytree('SFX','dist/SFX')6shutil.copytree('Image','dis... 阅读全文
posted @ 2007-12-02 22:21 吴尔平 阅读(1653) 评论(0) 推荐(0)
python 读取 windows event log 的简短代码
摘要:最近要把远程机器上的事件日志拿回本地分析,不过不管是直接在事件查看器另存还是用dumpel.exe备份,都不是很合自己心意。我一时又没找到更好的工具,不过手里有python啊。下面是简单的源代码,仅满足自已目前的需要 1 # -*- coding: cp936 -*- 2 def Usage(): 3 print '-f windows event log .evt格式备份' 4 ... 阅读全文
posted @ 2006-10-20 10:48 吴尔平 阅读(3422) 评论(0) 推荐(0)
IronPython 1.0 Release Candidate (转贴 ( 据说比c实现的快1.5!) )
摘要:IronPython 1.0 Release Candidate One of the great features of the .NET framework is the Common Language Infrastructure (CLI). The CLI provides a common foundation for a wide variety of programming l... 阅读全文
posted @ 2006-07-28 10:56 吴尔平 阅读(1095) 评论(0) 推荐(0)
BtTorrent 的 bencoding
摘要:bencoding是BT用来说明与组织数据的格式。BitTorrent-4.1.6\BitTorrent\bencode.py是算法的实现。bencoding相当简单,不过我还是写了一个UnitTest来验证我的理解。 1 import unittest 2 from BitTorrent.bencode import * 3 4 class testBencodeFun(unitte... 阅读全文
posted @ 2005-11-19 02:11 吴尔平 阅读(2429) 评论(0) 推荐(0)
用python快速开发一个实用的socket服务器
摘要:首先,要明白不是所有的socket服务都需要高性能。如果要求高性能,使用IOCP或EPoll模式用C/C++来完成,直接用API写,用ACE的proactor封装来完成是比较恰当的行为。但当性能不是主要问题时,用Python来写socket服务,并享受高的开发效率将是一件快乐的事。下面,是用python完成的一个每thread/connect的一个echo服务。 经常的,在写一... 阅读全文
posted @ 2005-10-29 23:25 吴尔平 阅读(30469) 评论(3) 推荐(0)
TinyP2P 世界最小的P2P应用
摘要:# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, E.W. Felten ar,pw,res = (sys.argv,lambda u:hmac.new(sy... 阅读全文
posted @ 2005-10-25 10:35 吴尔平 阅读(4115) 评论(1) 推荐(0)
python小代码:ElapsedTime
摘要:我在一个项目中用python做业务逻辑部分的代码,但速度不够理想,记录业务逻辑各段代码的用时情况并分析瓶颈就成了必须的工作。于是动手写了下面的ElapsedTime.PY,帮助解决问题。 import sysimport timeclass ElapsedTime: def __init__(self, scope = ""): self.scope_name ... 阅读全文
posted @ 2005-09-21 18:31 吴尔平 阅读(1184) 评论(0) 推荐(0)
浅尝boost.python
摘要:仍只是个坑 阅读全文
posted @ 2005-08-31 23:28 吴尔平 阅读(846) 评论(0) 推荐(0)