>>> '{lst.__len__()}'.format(lst=[1,2])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute '__len__()'
Plz help me out and thank you for your help in advance.....
>>> '{lst.__len__()}'.format(lst=[1,2])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute '__len__()'
Plz help me out and thank you for your help in advance.....
You can't call methods in string placeholders, You can only access attributes or also index the values.
For what you wanna do, you can do the following but it's not secure and you should use it with caution.
eval('{lst}'.format(lst=[1,2])).__len__()
Otherwise, well no, placeholders can't be used to invoke methods.