Inconsistency with split() - Script, OS, or Package Problem?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon May 9 20:00:34 EDT 2011
On Mon, 09 May 2011 15:09:32 -0400, James Wright wrote:
> Thank you Steven,
>
> I will take your advice :) In this particular case though, I do not
> think a lack of underscore is the issue, at least as far as I can
> understand the issue. Please see my reply to Ethan.
In your reply to Ethan, you inserted a print statement in the code and
got this output:
# python render4.py
current each_value is: vsr
Traceback (most recent call last):
File "render4.py", line 115, in <module>
create_report_index(each_item)
File "render4.py", line 26, in create_report_index
[clean_name, _] = each_value.split('_', 1)
ValueError: need more than 1 value to unpack
The current value of each_value is the three letter string "vsr". There
are no underscores in "vsr". Clearly the lack of underscore is the issue.
Now that this has been solved, it has revealed a deeper problem, namely,
how you get an empty key and "vsr" into your data on some machines but
not others.
If your script is behaving differently on different machines with the
same data, it is *far* more likely that there is something non-
deterministic in your code than that it is a bug in either the OS,
Python, or the virtualization environment. Without seeing either your
code or data, it is impossible to know what.
No offense, but are you sure it's not a PEBCAK error? Are you absolutely
sure you're running the same script the same way from the same data on
each virtual machine?
The fact that your script works correctly *once* when you rename it
doesn't strike me with confidence. Renaming the script shouldn't change
its behaviour.
I suppose it is just barely plausible that one of the VMs is reading its
data from faulty sectors on a disk, and hence gets inconsistent results,
but that is stretching the bounds of possibility almost to breaking.
You posted the data and script to Alex off list. Perhaps you could post
it again on-list? As they say, many eyes make bugs shallow.
--
Steven
More information about the Python-list
mailing list