Difference between " and '

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Jul 23 04:16:14 EDT 2005


On Fri, 22 Jul 2005 08:38:28 -0400, Peter Hansen wrote:

> Steven D'Aprano wrote:
>> It may shock some people to learn that difference in the sense of 
>> mathematical subtraction is not the only meaning of the word, but there 
>> it is. One wouldn't, I hope, misunderstand "What is the difference 
>> between spaghetti marinara and spaghetti pescatora?" and attempt to 
>> subtract one from the other, since subtraction is not defined for 
>> foodstuffs.
> 
>  >>> sum(ord(c) for c in 'spaghetti marinara') - sum(ord(c) for c in 
> "spaghetti pescatora")
> -119
> 
> Works for me... ;-)

Yes, but if you had thought about the problem a little longer, you would
have removed the spaghetti from both, since they just cancel each other.
Although that does assume that the commutative law holds for pasta
products.

Personally, I prefer this answer:

>>> import sets
>>> sets.Set("spaghetti marinara") - sets.Set("spaghetti pescatora")
Set(['m', 'n'])



-- 
Steven.





More information about the Python-list mailing list