Ive written a python program that used multiple instances of the contains syntax to look inside dictionaries and lists.
if not test_map[var].__contains__(string):
It seems that I would of been better to use :
if string not in test_map[var]:
Does anyone know the issues that can occur is using the __contains__
method ?
Thanks,
It's very very ugly.
Using the implementation directly instead of using the actual intended top-level syntax can also hurt you if the semantics are changed in the future. Plus, it makes the code much harder to comprehend and explain.
It's quite possible to be a competent Python programmer without knowing that in
uses __contains__()
under the hood. The reverse I would claim is not true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With