2016-08-09 13:18 GMT-07:00 Rob Gaddi <rgaddi@highlandtechnology.invalid>:
> Juan Pablo Romero Méndez wrote: > > > 2016-08-09 12:06 GMT-07:00 Paul Rubin <no.email@nospam.invalid>: > > > >> Juan Pablo Romero Méndez <jpablo.rom...@gmail.com> writes: > >> > In online forums sometimes people complain that they end up having to > >> > test constantly for None > >> > >> That's something of a style issue. You can code in a way that avoids a > >> lot of those tests (not all of them). > >> > > > > > > This is exactly what I'm looking for :). Do you have any resource (blog > / > > book, etc) that discusses this style? > > > > It's not a style, it's the absence of one. > > def add2list(lst, elem): > lst.extend([elem, elem]) > return lst > > I did all the type checking I needed to there; none whatsoever. If > passed a list, or something that behaves like one, that does the > expected thing. > > If passed an ExtensionLadder, it probably does the wrong thing, but that > is no way my problem. > So as the writer of the function you expect the user to read the function body to determine what is safe to pass or not? > > -- > Rob Gaddi, Highland Technology -- www.highlandtechnology.com > Email address domain is currently out of order. See above to fix. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list