Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5009

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

References <BANLkTi=g2h_BxZDdTdLqyB3nZCukD+Dupw@mail.gmail.com> <BANLkTinT+W-D8pr+sEAnFK_7k1WgmiP8iA@mail.gmail.com>
Date 2011-05-09 15:10 -0400
Subject Re: Inconsistency with split() - Script, OS, or Package Problem?
From James Wright <jamfwright@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1343.1304968241.9059.python-list@python.org> (permalink)

Show all headers | View raw


Hello Ian,

It does indeed to seem that way.  However the script works just fine
on other machines, with the same input file.


Thanks,
James


On Mon, May 9, 2011 at 2:41 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Mon, May 9, 2011 at 12:10 PM, James Wright <jamfwright@gmail.com> wrote:
>> 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
>
> You should check the value of each_value at the point when the script
> fails.  It sounds like split() is getting passed a string that doesn't
> contain any '_' characters at all, resulting in a sequence with only
> one value.  Passing 1 as the second argument ensures that there will
> be at most 1 split, but there may still be fewer.
>
> Cheers,
> Ian
>

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Inconsistency with split() - Script, OS, or Package Problem? James Wright <jamfwright@gmail.com> - 2011-05-09 15:10 -0400
  Re: Inconsistency with split() - Script, OS, or Package Problem? Alex Willmer <alex@moreati.org.uk> - 2011-05-09 13:02 -0700
    Re: Inconsistency with split() - Script, OS, or Package Problem? James Wright <jamfwright@gmail.com> - 2011-05-09 16:08 -0400

csiph-web