%Y-%h:%m:%s")
def add2 (x, y):
time.sleep (2) return
x + y
print add1 (1, 2)
print ADD2 (1, 2)
# Output:
-Run Ning ' Add1 ' on June 2013-13:40:47
-finished ' add1 ', execution time = 1.001s
3
-Running ' add2 ' on June 2013-13:40:48
-Finished ' add2 ', execution time = 2.001s
3
If you are careful enough, you may notice that we have a special treatment for the name __name__ of the return function, but not for other injections of __doc__ or __module__. So if, in this example, the
obsolete and is reserved for backward compatibility.The possible values are: Drtbs_none (in the configuration: None) and return the type after wrapping. Penaltyreturntypeonitsownline will be taken into account. Drtbs_all (in configuration: All) always wraps after the return type. Drtbs_toplevel (in configuration: toplevel) always wraps after the top-level function of the return type. Alwaysbreakafterreturn
(CLS)returncls.instance obj1=Singleton () obj2=Singleton () obj1.attr1='value1'print obj1.attr1, Obj2.attr1print obj1 isObj2In the above code, we associate an instance of the class with a class variable _instance , and if cls._instance None is created, the instance is returned directlycls._instanceThird, the use of decorative device from Functools import Wraps def Singleton (CLS ): Instances = {} @wraps
THREE. ImageLoader. load (paras) function is called again, and the THREE. Texture () constructor is called internally to generate a Texture. //////Example // load a CubeTexture, set wrap mode to repeat var images = [textures/water.jpg, textures/water.jpg, textures/water.jpg] var texture = THREE. imageUtils. loadTextureCube (images); texture. wrapS = THREE. repeatWrapping; texture. wrapT = THREE. repeatWrapping; texture. repeat. set (4, 4 );///*////Cu
Java basic data corresponding to the package class
Everything is class based in Java, and Java is encapsulating the basic data types, as shown below, introducing several basic data types and their encapsulated classes:
1 Boolean VS Boolean public final class Boolean extends implements,
The Boolean class wraps the value of the base type Boolean into an object. A Boolean object contains only one field with a Boolean type.
In addition, this class provid
THREE. Texture () constructor is called internally to generate a Texture. /////// Example // load a texture, set wrap mode to repeat var texture = THREE. imageUtils. loadTexture (textures/water.jpg); texture. wrapS = THREE. repeatWrapping; texture. wrapT = THREE. repeatWrapping; texture. repeat. set (4, 4 );///*////Texture///JavaScript Image type object ///Ing mode. For available constants, see the following comments ///S-direction coverage mode. For
()# I am doing some boring work before executing a_func ()# I AM the another function which needs some decoration to remove my foul smell# I am doing some boring work after executing a_func ()Here @a_new_decorator is equivalent to A_new_decorator (b_function_requiring_decoration)
6) Get NameFor the a_function_requiring_decoration in 4, we printed print (a_function_requiring_decoration.__name__) to get the result wrapthefunction , and what we actually want to get is the name of the A_function_re
specified element using an anonymous function contentInsertAfter (content) moves the specified node to the specified node element after content externalInsertBefore (content) moves the specified node to the specified node element before content outsideThird, the Parcel nodeWrap (HTML) wraps a layer of HTML code into the specified elementWrap (Element) wraps a layer of DOM object node $ (' div ') into the s
looking at the main () function, where the third call counter, and put the code out here.650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "/> 1classprogram2{3publicstatic voidmain () 4{5 counter (1,4,null); 6counter (1,4,new delegatebackcall (staticdelegatetoconsole));7 8counter (1,4,newdelegatebackcall (new Program (). Instancedelegatetomessage)); 9}10private voidinstancedelegatetomessage (Intnum) 11{12 console.writeline ("message:" +num);13 }14} 650)
the height of the Uilabel according to the content size
Copy Code code as follows:
Cgsize size = [Label.text sizeWithFont:label.font constrainedToSize:self.view.bounds.size Linebreakmode: Label.linebreakmode];
CGRect rect = label.frame;
Rect.size.height = Size.Height;
Label.frame = rect;
Line Wrapping Mode
Copy Code code as follows:
typedef enum {
Uilinebreakmodewordwrap = 0,//with space as the boundary, keep the whole word
Uilinebreakmodech
"Useful information for functions"例:def login(user, pwd): ‘‘‘ 功能:登录调用 参数:分别有user和pwd,作用分别是用户和密码; return: 返回值是登录成功与否(True,False) ‘‘‘ print"欢迎登录")print(login.__name__#查看函数名字print(login.__doc__) #查看函数注释login 功能:登录调用 参数:分别有user和pwd,作用分别是用户和密码; return: 返回值是登录成功与否(True,False)The name of the function. __name__ this is the way to see the names of the functionsThe function name. __doc__ This is the way to see the commentThe above two methods are useful in the Operation audit l
constructors
No Custom function
7, Boolean
Final class
Starting from 1.0 there are
Implement Java.io.serializable,comparable
The Boolean class boolean wraps the value of the base type in an object. An Boolean object of one type contains only one boolean field of type. In addition, this class boolean String provides many methods for reciprocal conversions and provides boolean some other constants and methods that are usef
member in the new class (i.e. inner Class) using the same type and name as the local variable used in the anonymous method body.3. Create a public instance method in a new class that wraps an anonymous method.4. Replace the declaration of the local variable with the declaration in the new class. Creates an instance of the new class instead of a local variable's declaration.5. Replace the local variables used in the body and external of the anonymous
following conditions:@deco1 (Deco_arg) @deco2 () def foo (): Passis equivalent to:def foo (): Passfoo = Deco1 (Deco_arg) (Deco2 (foo))
Manual decomposition of the 3.Python adorner execution processOK, with the theoretical basis above, it is easy to understand the following more complex adorner:Fromfunctoolsimportwrapsdeflog (text): defdecorator (func): @wraps (func) #it workslike:wraper.__name __=func.__name__defwrapper (*args,** Kwargs):pri
; @ decorator... def func (x ):... print x... decorator being called # using the func () function actually uses the decorated_func function >>> func () 1 >>> func. _ name _ 'corated _ func' if you want to ensure that the name of the returned decorated_func function is the same as that of func, add decorated_func.name = func before the decorator function returns decorated_func. name. In addition, the functools module provides the wraps modifier to comp
before the Decorator function returns DECORATED_FUNC. In addition, the Functools module provides a wraps decorator to complete this action.
# @wraps (func) operation equals # before return decorated_func, execution #decorated_func.__name__ = Func.__name__#func passed in as an adorner parameter, #decorated_ Func is passed as a parameter of the function returned by wrap
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.