Python Forum
How to modify __init__ of built-in module directly from the script?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to modify __init__ of built-in module directly from the script?
#4
(Jul-30-2018, 12:13 PM)sonicblind Wrote: If I would create my own class which would inherit from 'asm' class how would I attached this class to 'mgmt'?

You say you understand inheritance, yet, you want to modify the third-party package source?
If you inherit properly from Asm, your class will have all the functionality of the parent class, i.e. all the methods, properties, etc of Asm class. Of course without the one you override. I don't know what mgmt is or how Asm class is using it.
You show us how you want to change the __init__ method of the original code and I advise you not to mess with the original source, but inherit from it (of course you will need to properly use super() to initialize the parent - in your case Asm). If you override just the __init__ method (like you show in your original post) you will have all the functionality of Asm.
Also, assuming you write the violations policies and you will import it differently
How do you expect to be able to do this import
from f5.bigip.tm.asm.violations import Violations_s
when it does not exists?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: How to modify __init__ of built-in module directly from the script? - by buran - Jul-30-2018, 12:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Import XML file directly into Excel spreadsheet demdej 0 921 Jan-24-2023, 02:48 PM
Last Post: demdej
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,291 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,271 May-05-2022, 12:32 PM
Last Post: H84Gabor
  No module named '_cffi_backend' error with executable not with python script stephanh 2 5,890 Nov-25-2021, 06:52 AM
Last Post: stephanh
  using WinRt module in python script akhilgnair 0 2,160 Apr-23-2021, 05:38 AM
Last Post: akhilgnair
  How to load log.txt directly into python codes? sparkt 6 3,103 Aug-21-2020, 03:51 PM
Last Post: sparkt
  Get input directly as a number? Pedroski55 4 2,317 May-05-2020, 04:29 PM
Last Post: deanhystad
  TypeError indexing a range of elements directly on the list JFerreira 2 2,274 Mar-30-2020, 04:22 PM
Last Post: bowlofred
  modify script. MuhammadTalha 15 4,889 Nov-23-2019, 04:43 PM
Last Post: Gribouillis
  Is there any way to convert a python script (with Tkinter module), to a .exe (Windows moste 3 4,137 May-12-2019, 12:02 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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