Help with code-lists and strings

Dave Angel davea at ieee.org
Wed Jan 5 22:17:29 EST 2011


On 01/-10/-28163 02:59 PM, GrayShark wrote:
>
< <snip>
> In python it's best to build up you functional needs. So two steps. First
> a nand (negative 'and' operation). Then wrap that with a function to create
> two strings of your list element, you''re calling 'word'. By the way,
> list is reserved word, like string. Don't get in the bad habit of using it.
>
> def nand( a, b ):
> 	"""nand has to vars. Both must be strings """
> 	return( ( not eval( a ) ) and ( not eval( b ) ) )
>

Two problems with that.  One is that you've defined a NOR function, but 
called it nand().  The other is using eval.  There's no need for it, and 
it's both slow and risky.

DaveA



More information about the Python-list mailing list