len() should always return something

Marcus Wanner marcusw at cox.net
Fri Jul 24 16:25:57 EDT 2009


On 7/24/2009 4:18 PM, Mark Lawrence wrote:
> Marcus Wanner wrote:
>> On 7/24/2009 3:04 PM, Roy Smith wrote:
>>> In article <0279f596$0$5185$c3e8da3 at news.astraweb.com>,
>>>  Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
>>>
>>>> On Fri, 24 Jul 2009 16:50:03 +0200, superpollo wrote:
>>>>
>>>>>> Nah.  7 contains three bits, so len(7) should *clearly* return 3.
>>>>> and len("7") must return 8, by the same token... but wait!
>>>>>
>>>>>  >>> len("7")
>>>>> 1
>>>>>  >>>
>>>>>  >>>
>>>>> my python installation must me outdated ;-)
>>>> No no no, you're obviously using an awesome version of Python that 
>>>> can compress single-character strings to a single bit!
>>>
>>> Compressing strings to a single bit is easy.  It's the uncompressing 
>>> that's tricky.
>> I assume you mean ord("7")%2?
>>
>> First one to correctly decompress the value 0 into an ASCII character 
>> wins the title of the world's most capable hacker :p
>>
>> Marcus
> asciichar = chr(len(0)) if the OP's wishes come true?
> 
Nope, wasn't "?"...

Marcus



More information about the Python-list mailing list