Python single-and double-underline, python underline

Source: Internet
Author: User

Python single-and double-underline, python underline

1 underline. py 2 _ all _ = ['_ underline_variable', '_ underline_variable', '_ underline_func', 3' _ underline_func ',' _ underline_class ', '_ underline_class'] 4 5 6 _ underline_variable = 100 7 _ underline_variable = 200 8 9 10 def _ underline_func (): 11 pass12 13 def _ underline_func (): 14 pass15 16 class _ underline_class (): 17 pass18 19 class _ underline_class (): 20 pass21 22 23 class Base (): 24 def _ underline (self ): 25 pass26 27 def _ underline (self): # private 28 pass29 30 31 class Derived (Base ): 32 pass33 34 if _ name _ = '_ main _': 35 base = Base () 36 base. _ underline () 37 # base. _ underline () 38 base. _ Base _ underline () 39 40 derived = Derived () 41 derived. _ underline () 42 # derived. _ Derived _ underline () 43 derived. _ Base _ underline ()
1 test. py 2 #1 import 3 import underline 4 5 print (underline. _ underline_variable) 6 print (underline. _ underline_variable) 7 underline. _ underline_func () 8 underline. _ underline_func () 9 test1 = underline. _ underline_class () 10 test2 = underline. _ underline_class () 11 12 print ('* 20) 13 14 15 #2 NO _ all _ attribute defined, from... import 16 # from underline import * 17 # print (_ underline_variable) 18 # print (_ underline_variable) 19 # _ underline_func () 20 #__ underline_func () 21 # test1 = _ underline_class () 22 # test2 = _ underline_class () 23 24 25 #3 define the _ all _ attribute and use from... import 26 from underline import * 27 print (_ underline_variable) 28 print (_ underline_variable) 29 _ underline_func () 30 _ underline_func () 31 test1 = _ underline_class () 32 test2 = _ underline_class ()

 

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.