Why we use self and what happen when self is not use in the function
Help me to clarify this stuff...
info about self
Post a Reply
|Oldest Newest Rating|
· October 22, 2015
self is 'used' in objects (read oop (read object-oriented-programing)). basicly long story for a post, but it could be any word really : Python doesn't treat word self any diffrently than other words- Its like, before you define a variable called variable1, python wouldn't know what the hack variable1 is, so it will cry a error. Once you define it, python will know what the variable1 is, so it will work fine.
But in spirit of saint programers they established a religion which says: use word 'self'. It is told to be usefull, when reading code, after a programmer understanging the code faster.
So you can use (i suppose you learned about objects and classes) any word instead of self and it will work, if it is not used in objects ("the function"), it will be not do anything or it will works as any other word.
This section is all about snakes! Just kidding.
|Bucky Roberts Administrator|