#there is nothing like private or protected concept in python
#if we want to treat something as private we can use underscore '_'
# in front of the name,although it wont have any programming influence,
# but for the users understanding,also the objects starting with '_' won't be
# displayed if we use import *,although we can access using the modulename.objectname
# import blackjacktest1
# g = sorted(globals())
# for x in g:
# print(x)
# for x in globals():
# print(x)
# print (__name__)
# blackjacktest1.play()
#if you rename by prefexing any of the funtion with '_' and check the below loop will not return
#those funtions or objects
from blackjacktest1 import *
g = sorted(globals())
for x in g:
print(x)
#we can use '_' or '__' as variable name, thoughh it is not the proper way of naming variable
_ = 'a'
print(_)
__ = 'ab'
print(__)
personaldetails =('udai',23,'welcome')
name,_,__ = personaldetails
print(name,_,__)
Monday, 9 April 2018
Python - using underscore - Day 24
Subscribe to:
Posts (Atom)