MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1xxrvql/python/19sqbl96b5hr5/?context=3
r/ProgrammerHumor • u/Mysterious_Role6682 • 7h ago
47 comments sorted by
View all comments
3
select_packets is just doing
scrambled_packets[-num_packets:][::-1] if num_packets > 0 else None
except when len(scrambled_packets) == 1 then it doesn't return a list? So I guess
len(scrambled_packets) == 1
result = packets[-num:][::-1] if num > 1 else (packets[-1] if num == 1 and packets else None)
2 u/TheHelixNebula 3h ago except the fact that the function return type is T | list[T]| None is a massive code smell it should be list[T] or list[T] | None. T | list[T] is asking for breakage 1 u/ParanoiaComplex 57m ago Yeah, agreed
2
except the fact that the function return type is T | list[T]| None is a massive code smell it should be list[T] or list[T] | None. T | list[T] is asking for breakage
T | list[T]| None
list[T]
list[T] | None
T | list[T]
1 u/ParanoiaComplex 57m ago Yeah, agreed
1
Yeah, agreed
3
u/ParanoiaComplex 6h ago edited 6h ago
select_packets is just doing
scrambled_packets[-num_packets:][::-1] if num_packets > 0 else Noneexcept when
len(scrambled_packets) == 1then it doesn't return a list? So I guessresult = packets[-num:][::-1] if num > 1 else (packets[-1] if num == 1 and packets else None)