It's a common lightweight pattern: the first element says what kind of command it is, the rest are its arguments. The caller checks the first element and unpacks accordingly. For bigger systems you'd use classes or dataclasses, but for a console parser tuples are fine.
Comments 4
Join the discussion CommentAlready have an account? Log in
It's a common lightweight pattern: the first element says what kind of command it is, the rest are its arguments. The caller checks the first element and unpacks accordingly. For bigger systems you'd use classes or dataclasses, but for a console parser tuples are fine.
First element as the "type" — makes sense.
That trailing comma got me. Printed "abort" instead of "('abort',)".
Don't forget the comma in
("abort",)— without it, it's just a string in brackets.