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


Groups > comp.lang.python > #54900

Re: Hostrange expansion

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.054
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'string': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '11:32': 0.16; 'i.e.,': 0.16; 'range,': 0.16; 'so.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'library': 0.18; 'written': 0.21; 'code,': 0.22; 'accepted.': 0.22; 'cc:addr:python.org': 0.22; 'expanded': 0.24; 'specify': 0.24; 'cc:2**0': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'expanding': 0.29; 'have,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'sep': 0.31; 'me?': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'guess': 0.33; 'maybe': 0.34; 'basic': 0.35; 'created': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'in:': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'enough': 0.39; 'url:mail': 0.40; 'range': 0.61; 'show': 0.63; 'sam': 0.68; 'containing': 0.69; 'legal': 0.71; 'you\xc2\xa0': 0.84; 'joel': 0.91; 'url:domain': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yRV75fmsU9+6QP3QtglINi7KFPHIWJNGqr8GXlP4bbs=; b=OjnSSROVXx9RGIkIMQAE80r+32YhA/vsI31fIA+cGCfmXzs+hh7iga3cz07cCk3EMr pUwGRMtNWTAT7PXkmiaFM5Vo8P/VYZW9xeRh5g+FaCx67R9n+vdbPsYfE0vqYRASyLHP PH+vZlnf0s8dC7y3HR/zk1o9220vdacDqMuKhxoHhpuuWc5tqYaIK0Jsd7lWDWwmzHKZ UP/BB03rtw7NTu/HMaKzKjrXFejJBdPGxMkCHqLTDnKoHdMcBubvC+SKHIPJlNlRlkrR AnTLdCg+gYFnaOQ580fpj1dTF+iSzvBwvFQOMGoHZQlbANupHO1cyLV0pTf31Cl67bgl BK8Q==
MIME-Version 1.0
X-Received by 10.58.151.132 with SMTP id uq4mr2063674veb.30.1380302797360; Fri, 27 Sep 2013 10:26:37 -0700 (PDT)
In-Reply-To <CAC97zZ88AbQ497=uK0qG5NTPbQEfBXfmKVGFtEJHs_FDa=bFqw@mail.gmail.com>
References <CAC97zZ88AbQ497=uK0qG5NTPbQEfBXfmKVGFtEJHs_FDa=bFqw@mail.gmail.com>
Date Fri, 27 Sep 2013 13:26:37 -0400
Subject Re: Hostrange expansion
From Joel Goldstick <joel.goldstick@gmail.com>
To Sam Giraffe <sam@giraffetech.biz>
Content-Type multipart/alternative; boundary=047d7b6da644eb54f204e760c9c7
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.386.1380302806.18130.python-list@python.org> (permalink)
Lines 74
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1380302807 news.xs4all.nl 15931 [2001:888:2000:d::a6]:34179
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54900

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Fri, Sep 27, 2013 at 11:32 AM, Sam Giraffe <sam@giraffetech.biz> wrote:

> Hi,
>
> I need some help in expanding a hostrange as in: h[1-100].domain.comshould get expanded into a list containing
> h1.domain.com to h100.domain.com. Is there a library that can do this for
> me? I also need to valid the range before I expand it, i.e., h[1*100].
> domain.com should not be accept, or other formats should not be accepted.
>

You can loop on the range and create the list by appending strings created
with the range using string substitution.  No library involved, just basic
python language features.  As to the validation problem, I don't think you
have defined it well enough to advise you on coding.

Why don't you specify exaction what is legal or not legal for your range,
write the code, show us what you  have, and someone can help you further.
My guess is the code can all be written in maybe 20 lines or so.

>
> Thanks
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

Re: Hostrange expansion Joel Goldstick <joel.goldstick@gmail.com> - 2013-09-27 13:26 -0400

csiph-web