Suggestions for good programming practices?

Donn Cave donn at u.washington.edu
Tue Jun 25 12:57:37 EDT 2002


Quoth brueckd at tbye.com:
| On 25 Jun 2002, Chris Liechti wrote:
(someone said)
| > >> * Avoid exec, execfile, eval, and input.

| This view is a overly extreme. Rather than teaching people to fear certain 
| features like eval/exec, it's better to explain the risks so that they can 
| make informed decisions as to when it's wise to use them.

It's not overly extreme!  It's just about extreme enough.

| So... rather than teaching "avoid W!", let's say "be careful with W 
| because of X, Y, and Z". I still wouldn't use eval/exec on code posted 
| through a web form, for example, but there are times when they are very 
| useful and I can use them in good confidence because I understand their 
| risks.

But you weren't going to be deterred by that pronouncement anyway.

"Avoid exec, execfile, eval, and input" is good advice.  Taken at face
value, it doesn't necessarily absolutely prohibit their use - if I said
"avoid walking in the road", you could reasonably reasonably assume I'm
saying something like "walk on the sidewalk when possible".

Someone whose software engineering skills have been honed by years
of wrestling with ugly code monsters will apply a different perspective
to that advice.  A 1-week newbie could do worse than to follow that
advice religiously.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list