[Python] 1. **"Implementing custom string method 'joj()' in Python interpreter - RTResult...

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    Problem:
    When calling custom string method joj() (e.g., "hello".joj(2)), I get either:

    1. TypeError: Expected RTResult, got String, or
    2. AttributeError: 'function' object has no attribute 'arg_names'

    Traceback (most recent call last):

    File "interpreter.py", line X, in execute

    res.register(value_to_call.execute(args))


    AttributeError: 'function' object has no attribute 'arg_names'

    Relevant Code:

    # String class implementation
    def joj(self, index):
    res = RTResult()
    if not isinstance(index, Number):
    return res.failure(...)
    return res.success(String(self.value[index]))


    [download my project language blopy](https://ali-creatorui.iceiy.com/blopy/blopy.zip)


    bsay("hello me".joj(4)) # o

    `but error`

    Continue reading...

Compartilhe esta Página