Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Encapsulation in Python using public members

# illustrating public members & public access modifier 
class pub_mod:
    # constructor
    def __init__(self, name, age):
        self.name = name;
        self.age = age;
 
    def Age(self): 
        # accessing public data member 
        print("Age: ", self.age)
# creating object 
obj = pub_mod("Jason", 35);
# accessing public data member 
print("Name: ", obj.name)  
# calling public member function of the class 
obj.Age()
Comment

PREVIOUS NEXT
Code Example
Python :: How to count number of distinct elements in specified axis 
Python :: python 2.0 
Python :: should i learn c++ or python 
Python :: rename_and_convert_all_images_at_folder 
Python :: intersect and count in sql 
Python :: splitting x,y using iloc 
Python :: parse tree tags 
Python :: supervisor gunicorn virtualenv flask 
Python :: connect two mathod to the same button in pyq5 
Python :: discertize dara python 
Python :: find a string hackereank 
Python :: comment arrĂȘter un jeu en appuyant sur une touche python 
Python :: python tags 
Python :: pythongalaxy.com 
Python :: ipywidgets unobserve functools partial 
Python :: lamda in f string 
Python :: what is mysoace 
Python :: sns linear regression 
Python :: fibonacci sequence generator python 
Python :: when was python 3 released 
Python :: conversion of int to a specified base number 
Python :: flask request file upload to dropbox 
Python :: python boto3 ypload_file to s3 
Python :: vs python 
Python :: djago get settings 
Python :: python dynamic csvnfile joining 
Python :: how to click the next button on a website using python 
Python :: str vs rper in python 
Python :: pandas dataframe how to store 
Python :: pyttsx3 interrupting an utterance 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =