>
>Real question is what you're trying to do.  eval() and exec() are to be 
>avoided if possible, so the solutions are not necessarily the easiest.

I sometimes do something like
ifelse = "'teddybear' if bmi > 30 else 'skinny'"
weightcats = [eval(ifelse) for bmi in bmis]

Would this also be a *bad* use of eval? It can be avoided, but this is so 
concise.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to