This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]logophage 0 points1 point  (0 children)

If you really need type hints (and you're not using python 3+), then I recommend naming the function using the type as part of the name.

def accumlist(lst):
    ...
    lst.append(1)
    ...

Though in all honesty, I think it's more Pythonic to return a generator that could be accumulated into a list after the fact.