@Peilonrayz Even if it's seen as wrong, it does not mean it is imo. I have been told wrong here many times but a lot more times I noticed I wasn't wrong when I noticed what hypothesis was proved, even if not directly mentioned as being "right"?
@roganjosh if you can make a small file with the stuff you want to parse, I can make something that work
I have dealt with newline shenanigans on Linux before when I was parsing some weird format myself
@roganjosh that's why I said atomicity is not garanteed on Windows. Linux is much more respecting of atomicity though
mind you async != atomicity, but the problem is still related to asynchronousness anyway
@NordineLotfi I have got it working so there is no need, but thank you. The question is how to avoid going all round the houses trying to work out how to catch these subtle differences in a borked format. However, just the exercise yesterday probably equips me to plough through the options much faster in future. I suspect, if I wanted to be fancier, there will be something I could do in the terminal to get different highlighting when inspecting rows
@roganjosh not really. If you see "\n" printed out then that's a literal backslash and a literal n, one way or another (i.e. potentially from repr('\n')). If you were printing '\n' as a single character you'd see a line feed instead.
The problem here is that I was actively looking to check for the \n character myself. Part way through the mess there was a blank row and I wanted to snag that point and kill the parser. At first I thought if not next(row): would catch it, which it didn't (since it has a len()) so then I got into the silly mess I did with repr()
I've played a bit more since and I at least understand my mistake now... probably 8 years later than I should have, but hey ho
I actually do have code in a recent project to turn a context-managed file into a generator, for laziness
@roganjosh the brute-force approach to making sure you know exactly what every character is: list(map(ord, s))
never worry about confusing how many levels of string escaping are happening, or about unprintable or confusable characters, or getting duped by the bidi algorithm
at the low cost of seeing numbers in base-ten representation instead of meaningful text
but yeah, that while loop with next should really just be for
It certainly would work. It seems like you expect that it would load the file into memory first; why? The file object is a lazy iterator over its lines.
It would work for the same reason that the while loop with next does.
As long as you aren't doing something silly like list(infile) or infile.readlines() first.
Hopefully I only have to do this once. Adding ".rpt" to a file format isn't particularly helpful since there are apparently differing standards and I'm not working with either of the reported company formats
@roganjosh it would though? unless it does not have any newlines or each newlines/lines are over 1GB, then using open() with rb and using a chunk size would work
but as I said earlier, using open() + for loop would have worked better. feel free to try the example I made on my gist
I'm not sure it would have worked "better" because I was batching up the changes and writing incrementally to the file. If I used a for loop, I would still have had to catch StopIteration and dumped a partially-full buffer. The semantics of the loop itself wouldn't change the parse issue
I feel my trivial issue is taking up too much discussion; everyone is going to get bored. I should have known better on this parsing. I do now. Thanks all for the input :)
stackoverflow.com/questions/77571875 Okay, I'm at a loss. I get that this is homework, but... why would a BST have any application to the problem of looking for a palindromic substring?