--Make a note of what you thought was python.
――Perl is also called a mysterious language because it has various special variables such as $ _, but the promised keywords in any language are confusing at first. I think this is the first thing you notice.
if __name__ == '__main__':
--There was an explanation in Japanese. Reserved identifier species --Explanation of the head family. Reserved classes of identifiers
--Try some of the two underscores (\ _ \ _ xxx \ _ \ _) used in the system.
--When executed by a script, it becomes'\ _ \ _ main \ _ \ _', and when called from a module, it becomes the module name, and when called from a function, it becomes the function name.
>>> __name__
'__main__'
>>> def hoge():
... print(u'hello')
...
>>> hoge.__name__
'hoge'
――It comes out in the definition of the class.
>>> class MyClass:
... def __init__(self):
... self.name = "anonymous"
...
>>> a = MyClass()
>>> a.name
'anonymous'
-Special method name also has various explanations. If you remember this exactly, development will go smoothly.
--It is also objective-c to add \ _ in the member variable. --Don't access member variables directly with underscores! Does that mean almost the same?
Recommended Posts