Why return None?
me at privacy.net
Wed Aug 25 12:58:53 CEST 2004
On Wed, 25 Aug 2004 10:27:51 GMT,
Martin DeMello <martindemello at yahoo.com> wrote:
> Anthony Baxter <anthonybaxter at gmail.com> wrote:
>> On Wed, 25 Aug 2004 08:26:26 GMT, Martin DeMello
>> <martindemello at yahoo.com> wrote:
>> > It seems to be a fairly common pattern for an object-modifying method to
>> > return None - however, this is often quite inconvenient.
>> list.reverse() modifies the list in place. The python idiom is that
>> these don't return a reference to the modified list. Although note the
> Yes, but why? I mean, is there either an advantage to returning None or
> some inherent danger in returning self?
If list.sort returned the sorted list, how many lists would there be
after this code executed?
original_list = a_function_that_returns_a_list( )
sorted_list = original_list.sort( )
Never play leapfrog with a unicorn.
More information about the Python-list