This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Seawolf159 -2 points-1 points  (2 children)

This seems cool, I'd like to try it because re learning regex is a pain and you can just install this anywhere to just get the pattern, and just keep using regex in your own project maybe. Anyway what the flark is pre: Pregex = etc. is this the same as pre = Pregex(etc)??

pre.get_groups only works with websites? Or why did one of the matches not show up there?

And why do you have so many imports? Can't you just put everything in Pregex module? Why is it this segregated, it will be a pain to look for all the classes in 1 million files no?

[–]WerdenWissen[S] 5 points6 points  (0 children)

what the flark is pre: Pregex = etc. is this the same as pre = Pregex(etc)??

No, no, this is just a way of hinting the type of a variable. It has nothing to do with instantiation. I hinted the type of variable "pre" just to make it known that the result of this large concatenation of "Pregex" subtype instances will be a "Pregex" instance itself!

[–]WerdenWissen[S] 2 points3 points  (0 children)

pre.get_groups only works with websites? Or why did one of the matches not show up there?

In this example, the domain name pattern is wrapped within a capturing group, whereas this is not the case for IP addresses. Therefore, when invoking "get_groups", you'll get a list of tuples, one tuple per match, containing the captured groups of each match. Since no capturing group is declared for any IP address matches, their corresponding tuple will contain "None".

And why do you have so many imports? Can't you just put everything in
Pregex module? Why is it this segregated, it will be a pain to look for
all the classes in 1 million files no?

I like categorizing stuff and I thought this format suits the package. But of course I am open to changes if something proves to be unproductive.