Python Forum
how to get around recursive method call
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get around recursive method call
#7
your reply code shows it getting the attribute of something else using the name object. but i don't have that. i need to have it return the attribute of itself. thus, i need to find a way to get the attribute of itself without calling itself.

i want to have object A behave like object B except for intended differences. i implement the methods intended to be different. for the remaining methods, i don't even know what all they are, or will be in the future, so i implement __getattribute__ to pass references. that method ends up referencing itself to reference object B. because it references itself, it ends up calling itself.

def __getattribute__(self,attr):
    print(f'getting attribute {attr!r}',flush=True) # so i can see what is happening
    return self.objectb.__getattribute__(attr)
output will be one line for the first attribute then a few hundred for 'objectb', hence the recursion loop.

even your code will have this problem since it gets attributes inside itself.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: how to get around recursive method call - by Skaperen - Jun-30-2020, 10:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  method call help sollarriiii 6 1,356 Feb-21-2023, 03:19 AM
Last Post: noisefloor
  Combine Two Recursive Functions To Create One Recursive Selection Sort Function Jeremy7 12 7,792 Jan-17-2021, 03:02 AM
Last Post: Jeremy7
  list call problem in generator function using iteration and recursive calls postta 1 2,038 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  Return boolean from recursive class method medatib531 6 3,721 Jul-13-2020, 04:27 AM
Last Post: medatib531
  How to call COM-method using comtypes jespersahner 0 2,538 Nov-15-2019, 12:54 PM
Last Post: jespersahner
  Polymorphism not working with a call to a abstract method colt 3 2,448 Nov-04-2019, 11:04 PM
Last Post: colt
  How to Call a method of class having no argument dataplumber 7 6,808 Oct-31-2019, 01:52 PM
Last Post: dataplumber
  Call method from another method within a class anteboy65 3 7,713 Sep-11-2019, 08:40 PM
Last Post: Larz60+
  What is the use of call method and when to use it? everyday1 1 3,405 Jul-14-2019, 01:02 PM
Last Post: ichabod801
  I'm trying to figure out whether this is a method or function call 357mag 2 2,535 Jul-04-2019, 01:43 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020