May-17-2022, 03:30 PM
Hello,
I did many trials without success. I need to have flexibility in my Python code, so I use already .yaml configuration for deliverable scripts (generated executable from pyInstaller), but this is not enough.
I am trying to find out if it is possible to redefine some methods from a python wrapper script calling the executable binary script.
Below is the example:
wrap.py:
invest.py
foo.py
When I execute the wrap.py:
> python wrap.py
Traceback (most recent call last):
File "wrap.py", line 7, in <module>
Foo.displayParam = displayParam
NameError: name 'Foo' is not defined
Can someone provide me some advice ?
thanks a lot,
Pierre
I did many trials without success. I need to have flexibility in my Python code, so I use already .yaml configuration for deliverable scripts (generated executable from pyInstaller), but this is not enough.
I am trying to find out if it is possible to redefine some methods from a python wrapper script calling the executable binary script.
Below is the example:
wrap.py:
1 2 3 4 5 6 7 8 9 |
import os # import invest or ?? def displayParam( self ): print ( "overriden text" ) Foo.displayParam = displayParam os.system( "/prj/mms_nvm/cad_prj/python/users/paolipie/python/py_workdev/create_deliverable/dist/invest/invest" ) |
1 2 3 4 5 6 7 8 9 10 11 |
import sys from src.foo import Foo def main(argv): foo = Foo() foo.displayParam() # exec if __name__ = = "__main__" : main(sys.argv[ 1 :]) |
1 2 3 4 5 6 7 8 9 10 11 |
import sys import os from pathlib import Path # main class Foo: def __init__( self ): self .other = None def displayParam( self ): print ( "default text" ) |
> python wrap.py
Traceback (most recent call last):
File "wrap.py", line 7, in <module>
Foo.displayParam = displayParam
NameError: name 'Foo' is not defined
Can someone provide me some advice ?
thanks a lot,
Pierre