[Tutor] surprising len() results ???

Tom Cloyd tomcloyd at bestmindhealth.com
Tue Aug 9 11:10:37 CEST 2005


I'm running a program I wrote which I've run a number of times before,  

I use the following statement to fix the problem of utf-8 codes which blow  
up a later part of my production process that I cannot fix:

trans_table =  

As I said, this has been working fine. But no longer.

I previously have been running the ActivePython-2.4.1-247-win32 Python  
 from ActiveState, and executing my program in ActiveState's Komodo IDE.  
Due to some problems with the Boa Constructor IDE, I removed ActivePython  
and ran the Python 2.4.1 Windows installer from  python.org. I mention  
this because I'm wondering if this might be behind my problem. I'm still  
running from within Komodo.

Today, when running my program, when execution gets to the maketrans()  
function above, I get:

Traceback (most recent call last):
   File "C:\Program Files\ActiveState Komodo  
3.1\dbgp\pythonlib\dbgp\client.py", line 1799, in runMain
     self.dbg.runfile(debug_args[0], debug_args)
   File "C:\Program Files\ActiveState Komodo  
3.1\dbgp\pythonlib\dbgp\client.py", line 1524, in runfile
     h_execfile(file, args, module=main, tracer=self)
   File "C:\Program Files\ActiveState Komodo  
3.1\dbgp\pythonlib\dbgp\client.py", line 590, in __init__
     execfile(file, globals, locals)
   File "C:\Documents and Settings\Tom C\My Documents\Python projects -  
Toms\li-database\LI-db-use--dict_db.py", line 49, in __main__
     trans_table =  
ValueError: maketrans arguments must have same length

This makes no sense to me. So, I then broke up the maketrans() function  
statement's two parameters, and ran these two statements from within the  

print len('()ÄäÀÁàáÇçÈÉèéÌÍìíÑñÒÓòóÙÚúù')
print len('--AaAAaaCcEEeeIIiiNnOOooUUuu')

the result:


I'm completely mystified by this. All of it. None of it makes sense. This  
program was working fine. Now it doesn't. And those two parameter string  
are plainly the same length, but Python doesn't think so.

All help will be gratefully accepted!

-- t.

Tom Cloyd
Bellingham, Washington, U.S.A: (360) 920-1226
<< BestMindHealth.com / tc at bestmindhealth.com >>

Using Opera's revolutionary e-mail client (program):  

More information about the Tutor mailing list