What is the python equivalent of the Perl pattern to track if something has already been seen? -
In Perl, anyone can do the following
for (@foo) {# If If $ $ {$ _} ++; }
I want to be able to be equivalent to Python, which is to leave a block if it has been executed once.
seen = set () in foo for x: if seen in x: continue to view Keep it. See the documentation for more information. In addition, in the examples given below in the module document, there is a unique_everseen
generator that you can use in this way:
unique_ everseen ( Foo): # something
Comments
Post a Comment