Python 中的多个复合语句可以在一行中吗?

Can multiple compound statements in Python be in one line?

我有一些这样的代码:

def loongFunction(*args):
    if len(args) < 2:
        return
    else:
        x1 = args[0]
        y1 = args[1]
        if len(args) == 4:
            x2 = args[2]
            y2 = args[3]

这个函数可以得到的最小/惯用语是什么?

注意:如果len(args)是2,我不想声明x2y2

def loongFunction(*args):
    if len(args) > 1: x1, y1 = args[0], args[1]
    if len(args) == 4: x2, y2 = args[2], args[3]

如果您只是希望它尽可能短,您可以进行一些调整

def loongFunction(*args):
    if len(args) < 2: return
    x1, y1 = args[:2]
    if len(args) == 4: x2, y2 = args[2:4]