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


Groups > comp.lang.python > #54900

Re: Hostrange expansion

References <CAC97zZ88AbQ497=uK0qG5NTPbQEfBXfmKVGFtEJHs_FDa=bFqw@mail.gmail.com>
Date 2013-09-27 13:26 -0400
Subject Re: Hostrange expansion
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.386.1380302806.18130.python-list@python.org> (permalink)

Show all headers | 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