Inconsistency with split() - Script, OS, or Package Problem?

James Wright jamfwright at gmail.com
Mon May 9 14:10:21 EDT 2011


Hello,

I have been using a script on several boxes that have been around for
a while, and everything works just fine.  I am finding though, that on
some new OS installs the script fails with:

Traceback (most recent call last):
  File "render4.py", line 114, in <module>
    create_report_index(each_item)
  File "render4.py", line 25, in create_report_index
    [clean_name, _] = each_value.split('_', 1)
ValueError: need more than 1 value to unpack


The OS's are various OpenSuse installs from 10.3 to 11.4.  It works on
all the existing ones, which leads me to believe that I have a package
or configuration inconsistency. It should be noted though that I am
quite new to python programming and very well could have coded in a
non-portable manner and was just lucky to get it working in the first
place :)

Here is the code snippet that generates the failure (  when you look
at this remember that I am a novice :-)  ):

for each_item in D4:  #D4 is a dictionary
    create_report_index(each_item)

def create_report_index(report):  #Here we are creating a simple
index.html file from data in a text file
    newfile = open(report + '.html', 'w') #Create the index file using
report name
    for each_value in D4[report]:
        [clean_name, _] = each_value.split('_', 1)
        newfile.write('<a href="' + report +'//' + each_value +
'/index.htm">' + clean_name + '</a><BR>\n')


I've tried to match packages from a known working install and even
compiled a newer python (one known to work, version 3.1.3 in this
particular case).  The only discernible difference is that the new OS
installs are VM's hosted on VMWare ESX.  Using the same ISO I can spin
up a VirtualBox VM and the script works just fine.  I've tried this
with OpenSuse 11.3 and 11.4, once again, using the exact same ISO's to
install.

Do I have a Python, OS, or package issue?


Many thanks,
James



More information about the Python-list mailing list