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
Python. 

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

https://docs.python.org/3/library/cmd.html

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




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

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to