<div dir="auto">I’m guessing I can override float.__str__() and maybe the list.__str__() methods. Do I do that in x3d.py or my code?</div><div dir="auto"><br></div><div dir="auto">I’m on unfamiliar ground and will have to do some testing unless someone has a definitive response.</div><div dir="auto"><br></div><div dir="auto">I hope this works. I will run through the smoke tests provided.</div><div dir="auto"><br></div><div dir="auto">I will probably modify the Blender X3DV exporter first, and if that doesn’t work, proceed to modify x3d.py. I don’t think it’s a good idea to modify x3d.py itself.</div><div dir="auto"><br></div><div dir="auto">So far, I haven’t seen anyone replacing the str() function.</div><div dir="auto"><br></div><div dir="auto">John </div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 16, 2023 at 11:10 AM GPU Group <<a href="mailto:gpugroup@gmail.com">gpugroup@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div dir="ltr">It seems possible to override functions in python, if there are just a few to override.<div>And one suggestion for x3d.py imperfections is to apply fixes at runtime in some initialization function.</div><div>- that assumes/requires just a few target functions, not 480 functions that need to be repaired</div><div>- so for some fixes it may be helpful to change the upstream x3d.py to call a function that can be easily replaced.</div><div>-Doug</div><div>Example:</div><div>file myclass.py<div><div>class Wonky:</div><div> def __init__(self):</div><div> self.color = "Red"</div><div> def func1(self, color :str) -> bool:</div><div> if color == self.color:</div><div> return True</div><div> return False</div></div><div><br></div><div>file override.py</div><div><div>from myclass import *</div><div><br></div><div>mc = Wonky()</div><div>print("match with Blue? "+str(mc.func1("Blue")))</div><div><br></div><div>def func2(self, color: str) -> bool:</div><div> if self.color != color:</div><div> return True</div><div> return False</div><div>Wonky.func1 = func2 # <<<<<<<<<<<< OVERRIDE<br></div><div>print("don't match with Blue? "+str(mc.func1("Blue")))<br></div></div><div><br></div><div>output:</div><div><div>match with Blue? False</div><div>don't match with Blue? True</div></div><div>-Doug</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 16, 2023 at 9:55 AM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Instead of calling str() to print out a value, call a function that does precision floating point formatting on floats according to a user’s wishes. If the value is a list, call the function recursively with a list comprehension, otherwise, call str.<div dir="auto"><br></div><div dir="auto">I think this is doable by mere humans.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto"><br></div><div dir="auto">John</div>
</blockquote></div>
</blockquote></div></div>