Help with code-lists and strings
Dave Angel
davea at ieee.org
Thu Jan 6 06:38:01 EST 2011
On 01/06/2011 12:28 AM, Steven Howe wrote:
> On 01/05/2011 07:17 PM, Dave Angel wrote:
>> 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
>>
> Stupid.
> All code is risky.
> As to a nand operation, it not the same as a nor operation.
> Stupid
Well, if you're going to attack me, you could try to get your facts
straight. Of course namd is different than nor. If it were not, I
wouldn't have responded.
NAND is defined as NOT (A and B)
while NOR is defined as NOT (A or B)
What you defined was the contrapositive of NOR, but you called it nand()
If you need a refresher, check out
http://en.wikipedia.org/wiki/Negated_AND_gate
In particular, see the truth table, using ones and zeroes.
DaveA
More information about the Python-list
mailing list