python socket argument
Question: I have some problem in python's socket. I would like to write a class about
sync_file,and these are what I wrote.

    
    
    import socket
    class sync:
        def send_file(path,Socket):  #I would like to income two argument. First one is the file's path, and the second one is the socket object.
            f = open(path,"rb");
            line = f.read()
            f.close()
    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    a = sync()
    a.sendfile(file,s)
    

I thought I could send socket object as a argument, but it shows a error
message.It said that expecting number of argument is two, but I send three. I
wonder why it happened.


Answer: You forgot the `self` argument for the method:

    
    
    class sync:
        def send_file(self, path, socket):
          # ...
    

For method calls, Python automatically passes the object as first argument, so
your function gets three arguments but only expects two. Hence the error.

