[Python] Strange behavior in python resulting in the error: "TypeError: 'xxx' object is not...

Discussão em 'Python' iniciado por Stack, Abril 14, 2025.

  1. Stack

    Stack Membro Participativo

    Python ver 3.12.3

    This line existed (for a long time) in my python code:

    files= VGF.chronological_filenames_iter = VGF.chronological_filenames_iter(ti=ti, fname=name_pattern)


    The error is the leftmost equal sign, it should have been a colon (type hinting).

    However, the code above actually does what it is supposed to and the typing error are not noticed for weeks.

    Until this code;

    files: VGF.chronological_filenames_iter = VGF.chronological_filenames_iter(ti=ti, fname=another_name_pattern)


    ... are used in a different python module that is executed after the module which contained the typing error.

    Then an exception occurs, pointing to the second code snippet:

    TypeError: 'chronological_filenames_iter' object is not callable


    yes, I did spend several hours to figure why it crashed...

    To be clear; the 'chronological_filenames_iter' class, and the module where it resides (VGF), are both fine. No bugs there.

    Can anyone explain this python behavior ?

    Continue reading...

Compartilhe esta Página