Explain this process | Sololearn: Learn to code for FREE!


Explain this process

Guys i was making a (gui calculator) using (Tkinter). i understood all the process of the code but i didnt understood this part. please explain this.. # Calculate function scans the string to evaluates and display it def calculate(): entire_string = display.get() try: a = parser.expr(entire_string).compile() result = eval(a) clear_all() display.insert(0,result) except Exception: clear_all() display.insert(0,"Error")

8/25/2020 9:08:29 AM

Bhushan maghade

4 Answers

New Answer


Alright cool, well i told you what the meat of what it does. Ive seen pleanty made without the parser. but you can just look up online what the parser does


Show more code, idk where "parser" comes from. but it takes the string thats been typed and puts it through eval() wich evaluates strings as python code and sets the output to be the result. im just guessing clear_all() clears the display. and then the result is placed in the display


Yaa thanks for the explanation


The parser has been directly imported in s the starting of the code with tinkter and from math(factorial).