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


Groups > comp.lang.python > #5008

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jamfwright@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '>>>>': 0.09; 'subject:Problem': 0.09; 'valueerror:': 0.09; 'pm,': 0.11; '25,': 0.12; 'wrote:': 0.14; 'brackets,': 0.16; 'installs': 0.16; 'subject:split': 0.16; 'underscore': 0.16; 'underscore.': 0.16; 'unpack': 0.16; 'traceback': 0.16; '(most': 0.16; 'thanks,': 0.17; 'wrap': 0.19; 'header:In-Reply-To:1': 0.22; 'issue.': 0.22; 'mon,': 0.22; 'issue,': 0.23; 'last):': 0.23; 'script': 0.26; 'url:mailman': 0.27; 'message-id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'fine.': 0.29; 'least': 0.30; 'all:': 0.31; 'however,': 0.31; 'to:addr:python-list': 0.32; 'thank': 0.32; 'url:listinfo': 0.33; 'skip:e 20': 0.33; 'several': 0.33; 'using': 0.34; 'skip:" 10': 0.34; 'there': 0.35; 'file': 0.35; 'finding': 0.35; '"",': 0.35; 'fails': 0.35; 'wright': 0.35; 'allow': 0.36; 'hello,': 0.36; 'possibility': 0.36; 'think': 0.36; 'problem.': 0.36; 'data': 0.37; 'some': 0.37; 'case': 0.37; 'url:python': 0.37; 'subject:with': 0.37; 'steven': 0.38; 'received:google.com': 0.38; 'url:org': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'works': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'hand': 0.61; 'reply': 0.61; '2011': 0.62; 'received:74.125.83': 0.69; 'subject:Package': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=ebspKEZvhPtz+VQiBeVXvOxZ/0hHNZMe8LVHpPQYjVs=; b=vbiRaZEfBEbEvXl1ybh/xG2KS1NRiY0IRfLX8L8HZ0/olqo/ev+/Q1qSu88Lf0N8u5 3ybszbKTVhfkHhErJOdK2q3s5QkUQJ2qvv2xZ7sWizCwnnpVpzQXAlVvi2SkVAP/zEFx 5O8a7ldfITwA5MdBPnrOVHH/ALJwafD7J7F04=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=yGrVt24/vlk9wGvsfzJAaBtYNnTWcpGJe080bAiC32NfZ/9bwZjMDbCqQJcJyCGrAU wTzJJKLrFeKtGyLYfxWX4dVCkotSl34f68WS8K9jmeR2RLvW6Olou884yROozKf2mywF W+5rLhXp2NL/MVkU6WWOKcvsyL4lGavgVq1VI=
MIME-Version 1.0
In-Reply-To <4dc835bd$0$29991$c3e8da3$5496439d@news.astraweb.com>
References <mailman.1338.1304964624.9059.python-list@python.org> <4dc835bd$0$29991$c3e8da3$5496439d@news.astraweb.com>
Date Mon, 9 May 2011 15:09:32 -0400
Subject Re: Inconsistency with split() - Script, OS, or Package Problem?
From James Wright <jamfwright@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1342.1304968176.9059.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 82.94.164.166
X-Trace 1304968176 news.xs4all.nl 81482 [::ffff:82.94.164.166]:51000
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5008

Show key headers only | View raw


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.


Thanks,
James


On Mon, May 9, 2011 at 2:43 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 09 May 2011 14:10:21 -0400, James Wright 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
>
> It's a data issue, not an OS or package problem.
>
> Firstly, you don't have to wrap the left hand side in brackets, this
> works fine:
>
>>>> each_value = "aaa_bbb_ccc"
>>>> clean_name, _ = each_value.split('_', 1)
>>>> clean_name
> 'aaa'
>
>
> However, if your data has no underscore at all:
>
>>>> each_value = "aaa*bbb*ccc"
>>>> clean_name, _ = each_value.split('_', 1)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ValueError: need more than 1 value to unpack
>
>
>
> So you need to allow for the possibility that there is no underscore.
>
>
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Inconsistency with split() - Script, OS, or Package Problem? James Wright <jamfwright@gmail.com> - 2011-05-09 14:10 -0400
  Re: Inconsistency with split() - Script, OS, or Package Problem? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-09 18:43 +0000
    Re: Inconsistency with split() - Script, OS, or Package Problem? James Wright <jamfwright@gmail.com> - 2011-05-09 15:09 -0400
      Re: Inconsistency with split() - Script, OS, or Package Problem? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-10 00:00 +0000

csiph-web