Ian,

For the sanity of those of us reading this via Usenet using the Pan 
newsreader, could you please turn off HTML emailing? It's very 
distracting.
Thanks,

Steven


On Tue, 04 Dec 2012 12:37:38 -0700, Ian Kelly wrote:

[...]
> <div class="gmail_quote">On Tue,
> Dec 4, 2012 at 11:48 AM, Alexander Blinne <span dir="ltr">&lt;<a
> href="mailto:n...@blinne.net";
> target="_blank">n...@blinne.net</a>&gt;</span> wrote:<br><blockquote
> class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc
> solid;padding-left:1ex">
> 
> Am 04.12.2012 19:28, schrieb DJC:<br> <div class="im">&gt;&gt;&gt;&gt;
> (i for i,v in enumerate(w) if v.upper() != v).next()<br> &gt; Traceback
> (most recent call last):<br> &gt;   File &quot;&lt;stdin&gt;&quot;, line
> 1, in &lt;module&gt;<br> &gt; AttributeError: &#39;generator&#39; object
> has no attribute &#39;next&#39;<br> <br>
> </div>Yeah, i saw this problem right after i sent the posting. It now
> is<br> supposed to read like this<br>
> <div class="im"><br>
> &gt;&gt;&gt; def split_product(p):<br> ...     w = p.split(&quot;
> &quot;)<br> </div>...     j = next(i for i,v in enumerate(w) if
> v.upper() != v)<br> <div class="im">...     return &quot;
> &quot;.join(w[:j]), &quot;
> &quot;.join(w[j:])<br></div></blockquote></div><br>It still fails if the
> product description is empty.<br><br>&gt;&gt;&gt;
> split_product(&quot;CAPSICUM RED&quot;)<br>
> 
> Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;,
> line 1, in &lt;module&gt;<br>  File &quot;&lt;stdin&gt;&quot;, line 3,
> in split_product<br>StopIteration<br><br>I&#39;m not meaning to pick on
> you; some of the other solutions in this thread also fail in that
> case.<br>
> 
> <br>&gt;&gt;&gt; re.findall(r&quot;(?m)^([A-Z\s]+) (.+)$&quot;,
> &quot;CAPSICUM RED&quot;)<br>[(&#39;CAPSICUM&#39;,
> &#39;RED&#39;)]<br><br>&gt;&gt;&gt; prod_desc(&quot;CAPSICUM RED&quot;) 
> # the second version from Neil&#39;s post<br>
> 
> Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;,
> line 1, in &lt;module&gt;<br>  File &quot;&lt;stdin&gt;&quot;, line 14,
> in prod_desc<br>IndexError: string index out of range<br><br>


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to