Python Eval programming tutorial

preview_player
Показать описание
The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals and locals dictionaries as global and local namespace. If the globals dictionary is present and lacks ‘__builtins__’, the current globals are copied into globals before expression is parsed. This means that expression normally has full access to the standard builtins module and restricted environments are propagated. If the locals dictionary is omitted it defaults to the globals dictionary. If both dictionaries are omitted, the expression is executed in the environment where eval() is called. The return value is the result of the evaluated expression. Syntax errors are reported as exceptions.

Рекомендации по теме
Комментарии
Автор

Thank you for the video, my lecturing book is quite misunderstandable...

silverfluoride
Автор

list string
list strin
list stri
list str
list st
list s
list
liste
lister
listeri
listerin
LISTERINE!

So that's the secret to your pearly whites eh Harrison? :)
Loved your basics series. Thank you so much

abhishekmann
Автор

So why would one use eval? I don't get it

sliddjur
Автор

but isn't eval just as dangerous as exec, since you can always evaluate e.g. eval("exec('x=5')")? it actually works in python 3.5 on my pc

cardoran
Автор

You could also do this with regex very well but this is not the point. The question I have is can you acess a function with this previously defined by yourself in the "real" code?

mamazu
Автор

The dark side of the force is a pathway to many abilities some consider to be...unnatural.

JohnForbes
Автор

ure explanation and mine textbook explanation are bit different hence no idea who is correct and what is the usage of EVAL? but youre video was good

krishnasharma
Автор

String version of a dictionary is literally the same as json string...

Also eval is just not really useful unless you need to have built in scripting in python program for realtime evaluation.

purpleice
Автор

I have dictionary in a list
And using API to get that
So should I use Eval or pickle?

viveksingh-dcny
Автор

trying to find a solution for evaluating only mathematical expressions

SilverMiraii
Автор

Really?!? I wrote an extra function, that turns a  string like "(1, 4, 7, 2)" into a tuple... lol... ;)

Thx your tutorials are awesome!

niczwerg
Автор

you look like if snowden had a buzzcut and beard

secondsight
Автор

m working with anaconda what s that u re using pls !

fatihabamaarouf
Автор

Sir can u explain print(eval('1*-2'*2)) of output 42(how it works)

kurshitha
Автор

is it possible to make my own eval() function by myself????

theglobalconflict
join shbcf.ru