SyntaxFix
Write A Post
Hire A Developer
Questions
If you just need to know if you can use the foo[123] notation with the variable, you can check for the existence of a __getitem__ attribute (which is what python calls when you access by index) with hasattr(foo, '__getitem__')
foo[123]
__getitem__
hasattr(foo, '__getitem__')