r/PyScript • u/SamwiseGanges • Aug 08 '23
Using getPySrc() in <py-repl> element, AttributeError: 'Element' object has no attribute 'getPySrc'
Has anyone successfully used the getPySrc() method from the py-script element? It's mentioned here in the documentation but they provide 0 examples of how to use it. I have a py-repl element that I get a handle on in my Python code using the Element() method like so:
repl = Element("py-repl")
Then, I try to print the repl contents in a function like this:
def repl_test():
print(f"repl contents was {repl.getPySrc()}")
But I am getting the error "AttributeError: 'Element' object has no attribute 'getPySrc'". Is there some other way I'm supposed to get a handle on the py-repl element? The documentation says all the methods can be called from either Python or JavaScript so I don't see why this wouldn't work. Currently using pyscript 2023.03.1.
View all comments
Show parent comment
3
u/TheSwami Aug 10 '23
The
ElementAPI is indeed not great... even Fabio the original author owns up to it being a first implementation that's just hung around 😅