简体   繁体   中英

Why is this a python syntax error during an initialisation?

This code:

class Todo:
    def addto(self, list_name="", text=""):
        """
        Adds an item to the specified list.
        """
        if list_name == "":
            list_name = sys.argv[2]
            text = ''.join(sys.argv[3:]

        todo_list = TodoList(getListFilename(list_name))

produces a syntax error with the little arrow pointing to todo_list on the last line.

The __init__ method for TodoList is here:

def __init__(self, json_location):
    """
    Sets up the list.
    """
    self.json_location = json_location
    self.load()

I am kind of new to Python, so I don't see what I am doing wrong here.

您需要关闭此)

text = ''.join(sys.argv[3:]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM