Fix TypeError: ‘method’ Object Is Not Subscriptable

Quick answer: A ‘method’ object is not subscriptable when code uses square brackets on a bound method instead of on the value returned by calling it. Change object.method[index] to object.method()[index] when the method returns a sequence or mapping.

Python method object error infographic comparing object.method index with object.method call then index
Square brackets belong on the returned value; parentheses belong on the method call.

TypeError: 'method' object is not subscriptable means Python received square brackets on a method object instead of on a value that supports indexing. In most cases, the fix is to call the method with parentheses first, then use square brackets on the returned list, string, tuple, or dictionary value.

Square brackets call an object’s subscription behavior, commonly provided through __getitem__. Lists, strings, tuples, and dictionaries support it. A method object is callable, but it is not itself a sequence or mapping, so method[0] fails while method()[0] may be valid if the method returns an indexable value.

Quick fix

Look for a name followed directly by square brackets. If that name is a method, add () before the brackets or replace the bracket access with the correct method call.

<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;"># Wrong
user.name[0]
profile.get["name"]

# Right
user.name()[0]
profile.get("name")</div>

Method object example

In this example, name is a method. Writing user.name[0] tries to index the method object itself. The correct version calls name() first and then indexes the returned string.

<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">class User:
    def name(self):
        return "Python Pool"


user = User()
print(user.name()[0])</div>
P

If you omit the parentheses and run user.name[0], Python raises TypeError: 'method' object is not subscriptable. The difference is small visually, but it changes the operation completely.

Dictionary get() mistake

A very common version of this error happens with dictionaries. dict.get is a method, so it needs parentheses. Use profile.get("name") to call the method, or use profile["name"] when the key must exist.

<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">profile = {"name": "Ada", "scores": [10, 12]}

# Wrong: profile.get is a method object
# profile.get["name"]

print(profile.get("name"))
print(profile["scores"][0])</div>
Ada
10

Use get() when a missing key is possible and you want a default value. Use square brackets when you want Python to raise a key error if the key is missing.

Python Pool infographic showing a class instance, bound method, callable behavior, and method attribute
Method object: A class instance, bound method, callable behavior, and method attribute.

builtin_function_or_method is not subscriptable

You may see a closely related message such as TypeError: 'builtin_function_or_method' object is not subscriptable. That usually means a built-in method like append, sort, upper, or keys was indexed instead of called.

<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">items = []

# Wrong
# items.append[0]

items.append("ready")
print(items[0])</div>
ready

How to debug it

  1. Find the expression immediately before the square brackets.
  2. Print type(value) for that expression, or inspect it in the debugger.
  3. If it is a method, decide whether to call it with ().
  4. Check whether the method’s return value is actually subscriptable.
  5. Use callable(value) when you are unsure whether something should be called.
<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">value = "abc"

print(callable(value.upper))
print(callable(value.upper()))
print(value.upper()[0])</div>
True
False
A

value.upper is callable because it is a method. value.upper() is not callable here because it is already the returned string. That returned string is subscriptable, so value.upper()[0] works.

Python Pool infographic showing square brackets applied to a method instead of its returned list or mapping
Subscript error: Square brackets applied to a method instead of its returned list or mapping.

Square brackets versus parentheses

Use parentheses to call functions and methods. Use square brackets to index, slice, or look up a key. Mixing those two operations is the root cause of this error and several nearby TypeErrors, including callable-object mistakes and string-index mistakes.

Attribute versus method

One reliable way to diagnose this error is to ask whether the name should be an attribute or a method. An attribute stores a value, so indexing can be valid if that value is a string, list, tuple, or dictionary. A method performs work and must be called before you can use its return value.

<div class="pythonpool-code-scroll" style="max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;">class User:
    def __init__(self):
        self.name = "Ada"

    def labels(self):
        return ["admin", "editor"]


user = User()
print(user.name[0])
print(user.labels()[0])</div>

Here user.name[0] works because name is a string attribute. user.labels()[0] works because labels() returns a list. user.labels[0] would fail because it tries to index the method object rather than the list returned by the method.

Check the return value too

Adding parentheses fixes only the method-object part of the problem. The method’s return value still has to support indexing. If a method returns None, an integer, or another non-subscriptable value, the error message will change but the root cause is still an incorrect assumption about what the expression returns.

For example, list methods such as append() modify the list and return None. You should call items.append(value) on one line, then index items itself if you need to read an element afterward.

Python Pool infographic comparing method(), returned value, index access, and a corrected expression
Call then index: Method(), returned value, index access, and a corrected expression.

Why this error appears in real projects

This TypeError often appears after refactoring. A value that used to be a list or dictionary becomes a method that returns that data, but one caller still uses the old bracket syntax. It can also happen when copying examples quickly, especially with dictionary methods like get, keys, values, and items. Search for the expression before the bracket and confirm whether it now needs parentheses.

Related Python errors

Python Pool infographic testing parentheses, attributes, keys, slices, and callable state
Access checks: Parentheses, attributes, keys, slices, and callable state.

Official references

Call The Method Before Indexing

Square brackets ask an object for an item through its subscription protocol. A bound method is a callable object; it is not the list, string, tuple, or dictionary that the method may return. The missing parentheses are the key difference between selecting the method and executing it.

class Report:
    def rows(self):
        return ["header", "data"]

report = Report()
first = report.rows()[0]
print(first)

Spot The Missing Parentheses

Expressions such as items.copy[0], text.split[1], or data.keys[0] select a method object. The usual correction is items.copy()[0], text.split()[1], or a more direct operation such as next(iter(data)) when the returned object is not meant to be indexed.

Check The Return Type And API Contract

After adding the call, verify that the return value actually supports indexing. A method may return an iterator, set, generator, or None, none of which should be treated as a list without a deliberate conversion or alternative operation. Inspect type(result), read the method documentation, and avoid fixing the symptom by catching TypeError broadly.

Frequently Asked Questions

What does method object is not subscriptable mean?

It means square brackets were applied to a bound method instead of to the sequence or mapping returned when that method is called.

How do I fix a method object is not subscriptable error?

Add the method call parentheses before indexing, such as object.method()[0], when the method returns an indexable value.

Why does text.split[0] fail in Python?

text.split selects the split method; text.split()[0] calls it and then indexes the resulting list.

Can any method return value be indexed?

No. Check the return type because a method may return an iterator, set, None, or another object that needs a different operation.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted