samedi 12 mai 2018

Python see for which of the conditions the if any statement was true

I have a list of users (uniqueUsers) that I've sorted out from a Log-file.

Now I'd like to see which user is doing what and at what point and have used this if statement to check the entire log-file that I've read in:

if any(x in line for x in uniqueUsers) and "borrow" in line or "return" in line:

What I've done after this is to use a regular expression to get the user's ID from the line, but I started wondering if there would be any way for me to in a very short form get the user that Python found from this condition:

any(x in line for x in uniqueUsers)

Aucun commentaire:

Enregistrer un commentaire