<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:10pt"><br><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;">very well done..<br>But I thought it may require a little bit of change in the proposed code.. :)<br><br><span style="font-weight: bold; color: rgb(0, 0, 191);">def _revision_list_with_ranges_to_list_without_ranges(revision_list):</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> for revision in revision_list.split(','):</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0,
191);"> if '-' in str(revision):</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> from_revision, _, to_revision = str(revision).partition('-')</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> for revision_in_range in range(int(from_revision),</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> int(to_revision)+1):</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0,
191);"> yield revision_in_range</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> else:</span><br style="font-weight: bold; color: rgb(0, 0, 191);"><span style="font-weight: bold; color: rgb(0, 0, 191);"> yield int(revision)</span><br><br><br><div>cheers:<br>suneel kingrani<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;"><br><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Simon Brunning <simon@brunningonline.net><br><b><span style="font-weight:
bold;">To:</span></b> Seldon <seldon@katamail.it><br><b><span style="font-weight: bold;">Cc:</span></b> python-list@python.org<br><b><span style="font-weight: bold;">Sent:</span></b> Fri, 25 February, 2011 10:36:10 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: Parsing numeric ranges<br></font><br>On 25 February 2011 09:27, Seldon <<a rel="nofollow" ymailto="mailto:seldon@katamail.it" target="_blank" href="mailto:seldon@katamail.it">seldon@katamail.it</a>> wrote:<br>> Hi all,<br>> I have to convert integer ranges expressed in a popular "compact" notation<br>> (e.g. 2, 5-7, 20-22, 41) to a the actual set of numbers (i.e.<br>> 2,5,7,20,21,22,41).<br>><br>> Is there any library for doing such kind of things or I have to write it<br>> from scratch ?<br><br>I dredged this out:<br><br><br><br>def _revision_list_with_ranges_to_list_without_ranges(revision_list):<br> '''Convert a revision list
with ranges (e.g. '1,3,5-7') to a<br>simple list without ranges (1,3,5,6,7)'''<br> for revision in revision_list:<br> if '-' in revision:<br> from_revision, _, to_revision = revision.partition('-')<br>
for revision_in_range in range(int(from_revision),<br>int(to_revision)+1):<br> yield revision_in_range<br> else:<br> yield int(revision)<br><br>-- <br>Cheers,<br>Simon B.<br>-- <br><a rel="nofollow" target="_blank" href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></div></div>
</div><br><meta http-equiv="x-dns-prefetch-control" content="on"></div></div>
</div><br></body></html>