python - How are these return statements different -
this question has reply here:
why python's list.append evaluate false? 5 answerstake these 2 sample code statments:
result = [] homecoming result.append(feed.entries[0]) &
result = [] result.append(feed.entries[0]) homecoming result the first gives me error because method result passed complains of nontype not beingness iterable. why this? me both statements equivalent
the append method of list not homecoming anything
>>> = [] >>> type(a.append(12)) <type 'nonetype'> so when you're doing:
return result.append(feed.entries[0]) you're returning none in cases, whereas when do:
result.append(....) homecoming result you're returning list after has been mutated (modified) hence giving expected result.
python python-2.7
No comments:
Post a Comment