« first day (4792 days earlier)      last day (412 days later) » 

07:24
@roganjosh if you want to check if a new_line is an actual newline (the \n char) then just read it in binary mode, using rb.
@roganjosh so you want to distinguish between escaped n (\\n) and non escaped n, as in, newline? (\n)?
That's why I'll need to go back and look once I'm in work because it now seems that there are multiple ways to see "\n" being printed out
@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
also you might already know about it, but you know, might be better to use the context manager when you can rather than while loop + next :P
It is using a context manager? The point of next() is because I need to pull single lines from a file that's massively too big to pull into memory
07:42
oh, yeah you're right. I think I meant using open() (with for loop) instead of next()...didn't have morning coffee yet sorry
08:37
@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
08:56
if you did something like this, it would have worked better than repr: gist.github.com/secemp9/75f26182c0255801275d4004a7c4036e
09:29
@roganjosh I usually strip or rstrip lines for such parsing, which makes if not line work well.
09:41
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
A for loop wouldn't work on a 40GB file, though? For that simple example the while doesn't make sense but I just replicated what I was doing
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.
No, I wasn't doing anything that silly but I concede on this point. The file was driving me up the wall so lots of spaghetti to throw
09:56
no substitute for experience I guess.
10:09
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
10:50
@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
11:13
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
it would though, since using repr can be finicky. Just using rb would show the result correctly without using join/split/repr/etc
now for the batching part, I'm not sure I admit. I can't see your code so I'm just working with what you mentioned
repr() is totally separate to while/for with an if for break
I know, I guess I was only saying it would be better specifically for "repr" usage
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 :)
I'm never feeling bored here, but I guess that's fair. just wanted to help...
11:18
The screen space of my discussion here warrants something like a quantum computer explosion, not looking for newline characters :P
 
3 hours later…
14:20
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?
 
2 hours later…
16:18
@KarlKnechtel similar to this I'm guessing: stackoverflow.com/questions/60865117/…
I agree it's not optimal though. See this for a canonical about this: stackoverflow.com/questions/3183582/…
16:36
@NordineLotfi this one is specifically about searching for a constant "needle" that is known ahead of time, not any kind of pattern match.
it's also kinda irrelevant for Python programmers, because it's the implementation's job to implement the best such algorithm for the find method ;)
@KarlKnechtel I see :o I can't see deleted question so I was only going from when you said "palindromic substring"
I guess it could be seen as irrelevant, but I mean, isn't there a dozen of XYZ algorithm implementation question on SO using Python?
 
7 hours later…
23:19
@MisterMiyagi I always like wrapping iterators with generators (and sometimes with generators wrapped by other generators):

« first day (4792 days earlier)      last day (412 days later) »