News for hackers. Stuff that matters.
Re:Google Python Style Guide by PoignardAzur on Saturday February 11, 2023 @06:09AM (#34751279)
This bit in particular:

  if and_return:
    return greeting
Is a nice touch. I've definitely seen that pattern in the wild.
Re:Google Python Style Guide by davnn on Saturday February 11, 2023 @07:22AM (#34751721)
I can't conceive where this would be useful, could you expand on this?
Re:Google Python Style Guide by lozenge on Saturday February 11, 2023 @07:54AM (#34751933)
It's more likely to be listDir(withSizes=False)

I work on a very large codebase like this and most functions return lists of strings/tuples and most DTOs will be dictionaries with string keys. Instead of classes which have methods to retrieve information in different ways. Therefore parameters have been added to return information in more and more ways.

Re:Google Python Style Guide by goodoldneon on Saturday February 11, 2023 @08:05AM (#34751998)
I usually see it for things like “return_generator”. Then you need to write an overloaded signature to show that it could return a list or generator depending on that param.

Then it’s even worse when there’s also an “allow_raise” param, where the return type will not be None if allow_raise=True. Now you need to write 4 overloaded signatures to account for the 2 polymorphic params