Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53004

Re: python eval function

Subject Re: python eval function
From Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
Date 2013-08-26 19:43 +0430
References <mailman.228.1377474113.19984.python-list@python.org> <521aa76a$0$29986$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.237.1377530050.19984.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, 2013-08-26 at 00:55 +0000, Steven D'Aprano wrote:
> On Sun, 25 Aug 2013 23:48:34 +0430, Mohsen Pahlevanzadeh wrote:
> 
> > Dear all,
> > 
> > eval doesn't run my code at the following link:
> > http://stackoverflow.com/questions/18432198/eval-function-doesnt-work-
> in-python
> 
> 
> Are you asking a question or just sharing a useful link?
> 
> 
> 
> > Thank you before your answer...
> 
> What question do you want us to answer? The question on Stackoverflow has 
> already been answered correctly: there is no need to use eval (or exec) 
> for this basic task. 
> 
> Also, you're not writing C code. Get rid of the semi-colons, they are 
> just a waste of time, and make you look like an incompetent programmer.
> 
> Using exec is not the right solution. That is unsafe, if the field name 
> and content come from a database or external input, your code now has a 
> *serious* Code Injection vulnerability. AND it is slow. So you have 
> written slow, unsafe code. Get rid of it, and use setattr like you have 
> already been told:
> 
> setattr(self, fieldName, fieldValue)
> 
> 
> 
> -- 
> Steven
I didn't post a useful link,i questioned my problem.Of course, At first
i put it @stackoverflow then post its link for the following idea:
1. collecting votes for me and someone answered.
2. If anyone have my question in future, can use it.
Thank you for answer.

--mohsen

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

python eval function Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-08-25 23:48 +0430
  Re: python eval function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-26 00:55 +0000
    Re: python eval function Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-08-26 19:43 +0430

csiph-web