0

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")

25th Aug 2020, 9:08 AM
Bhushan maghade
Bhushan maghade - avatar
4 Respostas
+ 2
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
25th Aug 2020, 9:32 AM
Slick
Slick - avatar
+ 1
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
25th Aug 2020, 9:13 AM
Slick
Slick - avatar
+ 1
Yaa thanks for the explanation
25th Aug 2020, 9:38 AM
Bhushan maghade
Bhushan maghade - avatar
0
The parser has been directly imported in s the starting of the code with tinkter and from math(factorial).
25th Aug 2020, 9:29 AM
Bhushan maghade
Bhushan maghade - avatar