[Tutor] Python best practices
Kent Johnson
kent37 at tds.net
Mon Nov 30 02:22:35 CET 2009
On Sat, Nov 28, 2009 at 1:26 PM, Lie Ryan <lie.1296 at gmail.com> wrote:
> On 11/27/2009 7:03 PM, Stefan Lesicnik wrote:
>> - functions should return one value (im not 100% of this one)
>
> I 100% disagree or with this one.
Me too. Actually I think it is meaningless - every Python function
returns one value, an instance of some class. Each of these functions
returns one value - a list, a tuple and a Foo instance:
def make_list():
return [0, 1]
def make_tuple():
return 0, 1
class Foo(object):
def __init__(self, a, b):
self.a = a
self.b = b
def make_Foo():
return Foo(0, 1)
BTW when I first saw this rule I mis-read it as "Functions should have
a single point of return" which is fairly common advice that I also
disagree with.
Kent
More information about the Tutor
mailing list