News for hackers. Stuff that matters.
Re:Nim 2.0 thoughts by nerdponx on Sunday May 16, 2021 @07:56AM (#27173045)
I think the "full" version is easier to read:

    T = TypeVar("T")
    def odd_numbers(nums: Iterable[T]) -> Iterator[T]:
        for n in nums:
            if n % 2 == 1:
                yield n
Although yet another option is to just return the generator instead of immediately yielding from it:

    T = TypeVar("T")
    def odd_numbers(nums: Iterable[T]) -> Iterator[T]:
        return (n for n in a if n % 2 == 1)

There are no comments on this comment yet.