Poll on Eval in Python

K

Kazimir Majorinc

I am Lisp programmer and I write an article on issues
as macros, fexprs and eval. I want to compare opinions
of programmers of various programming languages on eval.

If you want to contribute your opinion on eval in Python
(or you want to look at result), the adress is:

http://kazimirmajorinc.blogspot.com

Thank you,
 
K

Kazimir Majorinc

I am Lisp programmer and I write an article on issues
as macros, fexprs and eval. I want to compare opinions
of programmers of various programming languages on eval.

If you want to contribute your opinion on eval in Python
(or you want to look at result), the adress is:

I need more voters, if you can, please.

blog: http://kazimirmajorinc.blogspot.com

Thank you
 
K

Kazimir Majorinc

THE RESULTS OF THE POLLS
========================

.. Lisp Python Ruby

Eval is evil,
harmful or at
least unnecessary 2 (4.9%) 7 (21.9%) 0 (0.0%)
----------------------------------------------------------
Eval is useful
but overused 11 (26.8%) 6 (18.8%) 9 (29.0%)
----------------------------------------------------------
Eval has just the
right place 16 (39.0%) 10 (31.3%) 19 (61.3%)
 
T

TerryP

And what about exec?


(note: exec in python is more in spirit of eval then C-style exec
functions)
 
K

Kazimir Majorinc

And what about exec?


(note: exec in python is more in spirit of eval then C-style exec
functions)

I thought about that, but decided not to ask about it
in poll, because I wanted to compare opinions on eval
specifically, not on all similar features. Do you think
it would be better if I asked that? That result would
be significantly different?
 
T

TerryP

Do you think
it would be better if I asked that? That result would
be significantly different?

Not really. The eval, exec, and compile builtins are more or less
related and serve similar purposes, but don't seem to be highly used
in Python. There's just not a great need of it in many typical
applications. That being said though, a language without the ability
to eval is like dancing with cement shoes ;).
 
N

Nobody

I thought about that, but decided not to ask about it
in poll, because I wanted to compare opinions on eval
specifically, not on all similar features.

One language's "eval" isn't the same as another's. E.g. there's a big
difference between Lisp's "eval" (which takes an s-expression as an
argument) and an "eval" which takes a string as an argument.

The former is fine; the latter should be prohibited by law, and preferably
by international treaty.
 
T

TerryP

One language's "eval" isn't the same as another's. E.g. there's a big
difference between Lisp's "eval" (which takes an s-expression as an
argument) and an "eval" which takes a string as an argument.

The former is fine; the latter should be prohibited by law, and preferably
by international treaty.


The ability to eval a string can be useful in generating code from a
template at run time, among other things. Of course, those who want to
cram tainted ``supercalifragilisticexpialidocious'' input from GOD
knows where into an eval statement, should just be shot, hung, drawn,
and quartered - no need for a legal opinion before hand.

There is no such thing as a feature that is absolutely always wrong to
use, just brain damaged people to use it inappropriately ;). Just look
at the TOPS family...
 
N

Nobody

The ability to eval a string can be useful in generating code from a
template at run time, among other things.

Only if that's the only eval that's available. If you have the option of
read-modify-eval (i.e. separate read and eval operations), that's almost
invariably preferable to the modify(string)-read-eval approach which
you're forced to use if parsing and evaluation are joined at the hip.
Although I'm not sure about the "almost".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top