[BangPypers] Return values

Sriram Karra karra.etc at gmail.com
Sat Sep 20 13:25:18 CEST 2014


On Sat, Sep 20, 2014 at 4:24 PM, Noufal Ibrahim KV <noufal at nibrahim.net.in>
wrote:

>
> This approach (especially with many calls) will make the API really
> big. I don't remember but I've seen things with get_something,
> get_something_list, get_something_dict and what not which don't really
> help readability.


That is true. But in my experience one of the biggest pain points in using
Python has been dealing with 3rd party libraries that are poorly documented
and have methods that return different types in different scenarios. It is
living hell with said library is packaged and distributed as a pyd. I have
come to avoid returning multiple types from a method - like the plague. All
that in addition to your valid concern about exploding API.

But your problem can be addressed by naming the functions after what they
do - after all your consolidate function does something tangible other than
just return a different type of data.


More information about the BangPypers mailing list