chris1610 / pbpython

Code, Notebooks and Examples from Practical Business Python
https://pbpython.com
BSD 3-Clause "New" or "Revised" License
1.99k stars 987 forks source link

Needing to consider the case of an empty list #17

Closed IcToxi closed 4 years ago

IcToxi commented 5 years ago

Hi Mr. Chris,

I recently learned the idea in your article Updated: Using Pandas To Create an Excel Diff , and I noticed that there was a function report_diff that did not take into account the case of empty lists. If there is no change, an error occurs. I think you should write like this.

def report_diff(x):

if any(x):

return x[0] if x[0] == x[1] else '{} ---> {}'.format(*x)

Thanks!

chris1610 commented 5 years ago

Yes. That's a good point. I'll update it shortly.

Thank you.

chris1610 commented 4 years ago

Closing this out. The updated article I posted includes a fix for this bug. Thanks for pointing it out!