0

How can i have this:

<bound method B.mutate_segment of <foo.B.B object at 0x0000000001269518>>

printed like "mutate segment of B"?

nanachan
  • 1,051
  • 1
  • 15
  • 26
  • maybe add your class definition first? `foo.B.B` seems odd here. – Dimitris Fasarakis Hilliard Sep 29 '16 at 17:53
  • foo.B.B here is that i am getting class B from another module called foo.py, so for printing i don't need the name "foo" to appear. – nanachan Sep 29 '16 at 18:00
  • then why is the method bound on `A`? Post your code, you'll make it easier for everyone to help. – Dimitris Fasarakis Hilliard Sep 29 '16 at 18:05
  • 1
    besides all the previous, why would you want to alter the `repr` of the `method` type? Apart from doubting if that's even possible, why would you want to do that? – Dimitris Fasarakis Hilliard Sep 29 '16 at 18:12
  • i made a mistake, the method is bound on B. I corrected the question. I need this for it for the log file, so that it looks comprehensible. – nanachan Sep 29 '16 at 18:46
  • Hey, read the question I linked as a duplicate. You can't really do this for the `method` type since you can't redefine `__repr__` for it (and can't create a specialized sub-class for it). I'm still curious though, why do you want to do this? – Dimitris Fasarakis Hilliard Sep 29 '16 at 18:49
  • ok, thank you, I will look into it. I need this for logging during a very long search process and it would be better if it looks more comprehensible among thousands of logged lines. – nanachan Sep 29 '16 at 18:51

0 Answers0