Python Learning: Adorner usage

Source: Internet
Author: User

1 #!/usr/bin/env python2 #Coding:utf-83 4Name="Alex"5psw="abc123"6 7 defAuth (func):8      defWrapper (*args,**Kwargs):9Username=input ('input your username:')TenPassword=input ('Input your password:') One  A          ifUsername==name andpassword==PSW: -             returnFunc (*args,**Kwargs) -          Else: the              Print('inalid username and password!') -      returnwrapper -  -  + @auth - defHome (): +     Print('Home') A     return 'home!!' at @auth - defadmin (): -     Print('Admin') - @auth - defBBS (): -     Print('BBS') in  - Home () to admin () +BBS ()

Add multiple types of validation

1 #!/usr/bin/env python2 #Coding:utf-83 4Name="Alex"5psw="abc123"6 7 defAuth (auth_type):8      Print('---------', Auth_type)9      defOut_wrapper (func):Ten          Print('---------', func) One          defWrapper (*args,**Kwargs): AUsername=input ('input your username:') -Password=input ('Input your password:') -  the              ifUsername==name andpassword==PSW: -                 returnFunc (*args,**Kwargs) -              Else: -                  Print('inalid username and password!') +          returnwrapper -      returnOut_wrapper +  A #added login multiple authentication at@auth (auth_type='file') - defHome (): -     Print('Home') -@auth (auth_type='localhost') - defadmin (): -     Print('Admin') in@auth (auth_type='LDAP') - defBBS (): to     Print('BBS') +  - Home () the admin () *BBS ()

Python Learning: Adorner usage

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.