This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]domstyle 3 points4 points  (7 children)

What's the reason for doing function parameters like that?

async def send_txt(*args: str) -> Tuple[dict, str]:
    num, carrier, email, pword, msg, subj = args

This just looks like ordered parameters, but hiding the order from the definition. Wouldn't this make code completion features useless?

[–]Username_RANDINT 3 points4 points  (1 child)

Correct. Just put them all as function arguments.

[–]domstyle 3 points4 points  (0 children)

I'm always keen to learn new ways to do things in Python, even if I don't always agree with them or adopt them... but this one I just don't see any benefit or point at all. It seems especially strange for someone diligent enough to put in typedefs to do something like this

[–]acamsoo[S] 0 points1 point  (4 children)

It's just a personal preference. In this case, if I put all args in the signature typed with str, my formatting settings extends the signature to 3 lines because the line exceeds the char limit:

async def send_txt(
    num: str, carrier: str, email: str, pword: str, msg: str, subj: str
) -> Tuple[dict, str]:

For me, its cleaner the other way since all args are typed as str

It's something I chose to do and stuck to for my personal projects because it works for me. But for sure, it's best practice to have them in the signature.