摘要:
Python的静态方法和类成员方法Python的静态方法和类成员方法都可以被类或实例访问,两者概念不容易理清,但还是有区别的:1)静态方法无需传入self参数,类成员方法需传入代表本类的cls参数;2)从第1条,静态方法是无法访问实例变量的,而类成员方法也同样无法访问实例变量,但可以访问类变量;3)静态方法有点像函数工具库的作用,而类成员方法则更接近类似Java面向对象概念中的静态方法。实现静态方法和类方法的两种方式一、在Python 2.3及之前,用staticmethod和classmethod类型对象包装实现例子如下(注意print里的说明): 1 class MyClass: 2 .. 阅读全文
摘要:
python may definetheir ownfuncin scriptto mimic __LINE__ in C language so as to grab the line make easier, it should be something like this:"""This provides a lineno() function to make it easy to grab the linenumber that we're on."""import inspectdef lineno(): " 阅读全文
摘要:
转载 http://blog.jobbole.com/21351/ 阅读全文
摘要:
转载 http://blog.csdn.net/mcsrainbow/article/details/2025729 阅读全文
摘要:
An overview of reboot cycling script.A top directory called rebooter designed by userA sub-directory call Reboot1. Reboot_run.bat =>this is a startup script used for full script copying from current dictionary to c:\reboot1 @echo off2 set ROOT_DIR=%~dp03 set TOOL_SRC=%ROOT_DIR%4 set TOOL_DES=C:\5 阅读全文
摘要:
转载http://www.ibm.com/developerworks/cn/opensource/os-cn-python-yield/【】 阅读全文
摘要:
C:\Users\Administrator>schtasks /Create /?SCHTASKS /Create [/S system [/U username [/P [password]]]] [/RU username [/RP password]] /SC schedule [/MO modifier] [/D day] [/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime] [/RI interval] [ {/ET endtime | /DU duration} [/K] [/XML xmlfi 阅读全文
摘要:
StringIO is usually used for buffer of string. which can have stdin,stdout,stderr redirected to a buffer.this moudle contains all of below methods.f=StringIO()#readyforwritingf=StringIO(buf)#readyforreadingf.close()#explicitlyreleaseresourcesheldflag=f.isatty()#alwaysfalsepos=f.tell()#getcurrentposi 阅读全文
摘要:
An simple example presentation 1 #inherit 2 class Parent: 3 '''reprensent parent''' 4 def __init__(self, name, age): 5 self.name = name 6 self.age = age 7 print'initialized parent:{}'.format(self.name) 8 def show(self): 9 print 'name:{0},age:{1}'.format(se... 阅读全文
摘要:
An example presentation 1 import sys 2 class test: 3 def __enter__(self): 4 print("enter") 5 return 1 # return value is assigned to 't' 6 def __exit__(self,*args): 7 print("exit") 8 #return True # True: raise statement is never executed, thinking n... 阅读全文