3/15/2023 0 Comments Rejex vs powelock![]() Or if you changed Interface to interface for one of the entries (no longer capital I) then the regex would raise the same error as above but the non-regex would simply ignore that entry. Or if you added some extra space at the end of any line then the regex would fail to see the newline right after the content and re.match(n, lock) would return None so the next line would raise an AttributeError: 'NoneType' object has no attribute 'group' The regex \s* would deal with the extra space fine but the non-regex parsing would assume that lines.split(':') has an indice so it would raise an Inde圎rror with that data Or if you added an extra newline between input and output like this: Interface 1/2 Self.IFlist = īoth of your methods use specific aspects of the format to achieve the parsing you are trying to do, and if that format was changed / broken one of the methods could also break.įor example if you added a space in the empty line between the two entries (which you cannot see) then the blocks = ('\n\n') would fail to find two consecutive newline characters and the regex version would miss out on the second entry: Valuelist.append((lines.split(':')).strip()) Input self.output to these functions will be something like this: message = Readline2 uses re module and match the groups and from groups it writes to dictionary keys and values. Readline1 gets a list from readline and processes output and writes into the dictionary with key as interface name and values as next three items. I would like to know which one should I use for efficiency and which one looks more prone to fail for bigger data samples. I have two approaches to do the same task. Supposedly it will last 4 years.I have a text to process (router output) and generate useful data structure (dictionary having keys as iface name and values as packet counts) from it. When I did my CX-5 last year it took over 15 hours not counting the cure time for the ceramic coating. Trying to get myself psyched up for that event. I have to detail my wife's car next which will be a 10 hours of cleaning to prepare for the coating. P
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |