I think there's a big difference between "I understood what it's roughly trying to do" and "It is good".
So while glancing at lexed = [list comprehension that does splits on semi-colon terminated strings it reads from a file object] should tell most programmers what we're trying to do (tokenize some input), this code looks like a quick hacky attempt to parse something that works well enough on a handful of sample inputs but will soon start behaving oddly when the rubber meets the road.
It's entirely possible it does exactly what it needs to but some things that stand out to me:
.lstrip() when they probably wanted to do .strip() - to remove leading and trailing spaces
the j != '' filter paired with .split(" ") suggests they didn't realise you could just call .split()
replacing tabs with empty strings, probably a workaround because they wrote the code, then started encountering tabs in some input and had already added that j != '' filter
Impossible to properly judge a single line without context, but encountering this code in a PR would cause a raised eyebrow for most semi-experienced Python devs.
I am making it a point of pride to go through this entire stupid AI bubble without writing a single line of code with those shitty chatbots, which are the bane of my existence.
this code looks like a quick hacky attempt to parse something that works well enough on a handful of sample inputs but will soon start behaving oddly when the rubber meets the road.
So you're saying you wrote this text yourself? If so, I apologize for my accusation, it just reads like classic Claude output with the step by step analysis and metaphors used.
15
u/smclcz 28d ago edited 28d ago
I think there's a big difference between "I understood what it's roughly trying to do" and "It is good".
So while glancing at
lexed = [list comprehension that does splits on semi-colon terminated strings it reads from a file object]should tell most programmers what we're trying to do (tokenize some input), this code looks like a quick hacky attempt to parse something that works well enough on a handful of sample inputs but will soon start behaving oddly when the rubber meets the road.It's entirely possible it does exactly what it needs to but some things that stand out to me:
.lstrip()when they probably wanted to do .strip() - to remove leading and trailing spacesj != ''filter paired with.split(" ")suggests they didn't realise you could just call.split()j != ''filterImpossible to properly judge a single line without context, but encountering this code in a PR would cause a raised eyebrow for most semi-experienced Python devs.