Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

self.variable

// no need to define variables explicitly like in java or c++
// we need to define them in __init__ method that creates, this i8s the key 
// __init__ basically it's constructor
// instance variables for the current object self( which denotes your created instance)
class A:
 def __init__(self,d):
     self.d=d
//above automaticaaly creates an instance variable d for you class object
hence 

ob=A(4)
// creates object ob with 1 instance variable d initialised to 4 

ALSO NOTE:
// in python there is no distinction between pointer variable and 
// normal variable we use same syntax for both unlike c++
// so how python distinguishes b/w a reference and normal var?
// by seeing what is being assigned to it on RHS
Comment

PREVIOUS NEXT
Code Example
Python :: lstm pytorch documentation 
Python :: django template filter 
Python :: multiline comment 
Python :: python script to read qr code 
Python :: initialize 2d array of zeros python 
Python :: how to run multiple python files one after another 
Python :: numpy difference between two arrays 
Python :: eval() function in python 
Python :: how to convert one dimensional array into two dimensional array 
Python :: how to iterate tuple in python 
Python :: text to speech module python 
Python :: do i need do some set when i use GPU to train tensorflow model 
Python :: circular linked list in python 
Python :: email validation using django 
Python :: api key python 
Python :: python type checking boolean 
Python :: label encoding of a column in python 
Python :: python encoding declaration 
Python :: receipt parsing 
Python :: first non repeating charcter in string ython 
Python :: flask_jinja structure 
Python :: pygame screen 
Python :: python global keyword 
Python :: expand figure matplotlib 
Python :: customize path in url 
Python :: john cabot 
Python :: wxpython menu callback stackoverflow 
Python :: roll dice python 
Shell :: chrome remote debug 
Shell :: woeusb ubuntu install 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =