Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

use of self in pythonic class

don't confuse self with head in a Node class for a linked list or a tree
self is just used inside class to access non static methods and attributes for
this 'self' object you created
1) self.attribute=value
2) self.non_staticmethod()

# don't go on using self keyword itself inside the non static functions 
# like in a linked list new=self instead of new=head
# one reason to present above argument is that using class A(object)
# functions can be made static and self is then not required at all
# although above argument has flaws but still just use self for those 2 purpose only
(opinion is subject to change in future)
Comment

PREVIOUS NEXT
Code Example
Python :: program in python to print first 10 natural number. 
Python :: python default dictionary 
Python :: eval() function in python 
Python :: python elif syntax 
Python :: ceil in python3 
Python :: how to add number to string in python 
Python :: python true and false 
Python :: separate digits with comma 
Python :: function to measure intersection over union 
Python :: how to add one to the index of a list 
Python :: selenium python get image from url 
Python :: add to list python 
Python :: armstrong number function 
Python :: how to make a programming language in python 
Python :: python frozenset 
Python :: convert uppercase to lowercase and vice versa in python 
Python :: python range function examples 
Python :: Merge multiple dataframs 
Python :: editing specific line in text file in python 
Python :: qtablewidget add row python 
Python :: how to add keyboard to python turtle 
Python :: how to remove last element from a list python 
Python :: simple click counter in python 
Python :: lowering the time.countdown python 
Python :: plant python documentation 
Python :: file = Root() path = file.fileDialog() print("PATH = ", path) 
Python :: taggablemanager serializer django 
Shell :: how to check laptop serial number in ubuntu 
Shell :: how to upgrade pip 
Shell :: sudo: unzip: command not found 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =