On Wed, 12 Oct 2016 08:59 pm, mr.puneet.go...@gmail.com wrote:

> Now person who wants to write a script using above package can simply use
> below approach. Which does not make him to have knowledge in python.
> DUT = platform()
> DUT connect
> DUT config {commands}
> DUT show {commands}
> DUT destroy
> But I know this is not easy to do in python. 

This is *impossible* to do in Python. You cannot expect to write something
in a language which is not Python, and have the Python interpreter run it
as Python code.

Either your users have to write Python code, or you have to write your own
interpreter for whatever language it is that they wish to write. The
interpreter doesn't need to be very complicated, and it can be written in

The Python standard library includes support for writing *interactive*
command interpreters:


You can study that to get some hints for writing a non-interactive

“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.


Reply via email to