This is a I have not solved the face of the question!! Python decorator

Source: Internet
Author: User
Tags python decorator

Here is a question I wrote!!! Under the closed principle of satisfying function, the indefinite length parameter of the printing function is realized, and the execution time of the printing function is implemented.

Who can who can implement the following print function call method???

Import TimedefOuter (func):defInner (*args,**Kwargs): Start=time.time ()Print("*****") func (*args,**Kwargs) Time.sleep (0.5) Stop=time.time ()Print(stop-start)Print(*args,**Kwargs)returnInner@outerdefF (A, B):Print("11111") F (1,[12,156])

There's one more question. Think your solution is clumsy, the topic is to use a function to achieve a sequence of adjacent to the weight, the sequence can be a string, list, pairs tuples group.

The idea is: first the original so that the sequence of the implementation of the list conversion, and then proceed with the next comparison, if not the same will be append to a new list , if the same is skipped, and finally converted to the corresponding data type.

If there is a good idea please comment me thank you!

def func (squence):     " squence can be string, tuple, list "              = List (squence) = 0 = [] While cur < (len (      Mid)-2):        if mid[cur]! = mid[cur+1]:            lista.append (mid[cur])            cur+=1    Print(ListA) func ([1,22,22,33])

This is a I have not solved the face of the question!! Python decorator

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.