Compare two variables

Hi all,

I have this line that shows us the files transactions in a folder

path = "transaction.log." + date + "*"

The output is the below:
[‘/cxpslogs/powerBI/pruebasTransaction/testivan/transaction.log.2024-05-10.cexpgtap4p.gz’, ‘/cxpslogs/powerBI/pruebasTransaction/testivan/transaction.log.2024-05-10.cexpswap4c’, ‘/cxpslogs/powerBI/pruebasTransaction/testivan/transaction.log.2024-05-10.cexpswap4c.old’, ‘/cxpslogs/powerBI/pruebasTransaction/testivan/transaction.log.2024-05-10.cexpswap4p’]

Mi question is the below:

I need to compare the files store in the variable against another variable called message

print ( message )
This output show us
[‘/cxpslogs/powerBI/pruebasTransaction/testivan/messagelog.2024-05-10.cexpgtap4p.gz’, ‘/cxpslogs/powerBI/pruebasTransaction/testivan/message.log.2024-05-10.cexpswap4c’]

'I need to compare the two variables and The output should show me the file transaction
[‘transaction.log.2024-05-10.cexpgtap4p,transaction.log.2024-05-10.cexpswap4c’], because i need to work with each message ordered. What do i need to do? create any list, dict?


Is your question how to get a diff between to lists?
Does python’s difflib provide a solution? See difflib — Helpers for computing deltas — Python 3.12.3 documentation

Hint sort both lists first then use difflib on the sorted lists.

P.s. read this to see how to format code and program output nicely: About the Python Help category


print ( aux )

I have this output:

I need to obtain a pattern for each file within the variable to work it

For example this output I need: [ ‘cexpswap4c’,‘cexpswap4p’] in a new variable

‘cexpswap4c’,‘cexpswap4p’ are the hostname

How can I cycle through the variable and extract the pattern?