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")
4 Réponses
+ 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
+ 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
+ 1
Yaa thanks for the explanation
0
The parser has been directly imported in s
the starting of the code with tinkter and from math(factorial).