|
Having a bit of an argument with a friend regarding private functions in Python. He believes they cant be done. I indiciated that a class that contains a private copy of a method techincally is a private function, like the example in section 9.6 here: https://docs.python.org/3/tutorial/classes.html#tut-private. Please convince me Im either right or wrong PS this all goes back to an ADT argument where ADTs are not implemented the same on Python as say, C.
|
# ¿ Oct 21, 2022 18:14 |
|
|
# ¿ May 12, 2024 17:13 |
|
Thanks for the feedback. I think I have a little better idea what is going on.
|
# ¿ Oct 23, 2022 01:00 |
|
Maybe this doesnt belong here but it is python related so here it goes: How do I use a conditional within a regex expression? The string is like this: {some text} {timestamp in the form: '12:22:59:987654'} {more text} {text I want to match} {numerical data} I only want to pull timestamps for the text I want to match. Im using this regex string to pull the timestamp: r'\d{2}:\d{2}:\d{2}.\d{6} Never done this before so thought I would ask the group.
|
# ¿ Mar 5, 2024 01:41 |
|
The Fool posted:should be able to use capture groups: https://docs.python.org/3/library/re.html#re.Match.group Thats awesome, but I dont want to store them in a tuple but rather a list.
|
# ¿ Mar 5, 2024 02:24 |
|
necrotic posted:Pass the tuple to list() then? Yeah thats cool. I just want to store the time given certain text in the line of a file. An example is: '(\b\d{2}:\d{2}:\d{2}.\d{6}).+(\b[uplink]+\b)", the first part being the timestamp and the second part being the text I am interested in filtering by. Any subsequent lines that dont contain that text, im not interested in collecting. Its then those times I want to store in a list.
|
# ¿ Mar 5, 2024 03:45 |
|
|
# ¿ May 12, 2024 17:13 |
|
^^ yes the format was a .log file. What I did was look for the specific text I wanted and then filtered out those timestamps into a list. Since I needed to do this twice (one for upload and another for download), I decided to have two seperate lists to read from. And yeah I was trying to see if I could extract only two specific strings from a line of text (which I learned can be done using groups).The Fool posted:iterate the lines, if it does't match it returns None, if it does it returns group(0) as a string, append to your list Thanks for this. This is what I ended up doing after playing around with it for a while. DELETE CASCADE posted:yes but i want to embed all of my logic in the regex don't you see? haha yeah this is what I wanted to do. I came to the point that regex and grouping only takes you so far. Tacos Al Pastor fucked around with this message at 16:40 on Mar 5, 2024 |
# ¿ Mar 5, 2024 16:36 |