First python-review-

I've finished one python beginner's book. In the second week, I will write down what I forgot.

** Command line arguments ** You can pass values to the program when you run the program from the shell. This value is called a command line argument.

Command line arguments


>>>python effective file name command line argument 1 command line argument 2 ...

argv [0]: Effective file name argv [1]: Command line argument 1 argv [2]: command line argument 2

** Error handling ** try, except: If there is an error in the try part, except processing is performed.

** join method ** Insert a string between all elements.

join


>>>"-".join(["a","b","c"])
"a-b-c"

** map function ** Returns a list of the results of applying the function to all the elements of the list as arguments.

join


>>> map(str,[1,2,3])
["1","2","3"]

** How to raise an error ** Use raise.

raise


raise Exception("It is an error")

** super (data_kata, self) function ** A function that takes two arguments, the name of the data type and self, and returns its parent class. When inheritance is used when creating a class, if you write a method with the same name as the one in the parent class in the child class, the method of the parent class will be overwritten. Be especially careful when adding initialization methods! Call super (oya, self) and then add the code.

** Important here! ** ** -Variables used in the function should be those defined inside the function or those received as arguments.

Recommended Posts

First python-review-
First draft
First gdb
First time python
First Windows 10 hack
First Python 3 ~ First comparison ~
First Django Challenge
First command plugin
First time python
First Python ~ Coding 2 ~
First image classifier
First python [O'REILLY]
First Django development
[IOS] First Pyto