Message88711
| Author |
loewis |
| Recipients |
Rhamphoryncus, benjamin.peterson, claymation, ezio.melotti, giampaolo.rodola, gregory.p.smith, gvanrossum, loewis, mattsmart, oubiwann, pitrou, pmoody, pnasrat, r.david.murray, shields |
| Date |
2009年06月02日.05:19:18 |
| SpamBayes Score |
0.00014832447 |
| Marked as misclassified |
No |
| Message-id |
<4A24B627.6060307@v.loewis.de> |
| In-reply-to |
<8657ee3f0906011747u213e7727w205f568189960636@mail.gmail.com> |
| Content |
> Consider applications that need to validate addresses (or networks,
> but not both) supplied as user input:
>
> address = ipaddr.IP(input)
If that is a frequent need, it would be reasonable to add an API
address = ipaddr.IP(input, allow_mask=False)
which would raise an exception if a mask was specified (as an
old-style bit mask, or in CIDR form).
> if isinstance(address, ipaddr.IPv4):
> if address.prefixlen != 32:
> raise TypeError("Expecting IP address, not network")
> elif isinstance(address, ipaddr.IPv6):
> if address.prefixlen != 128:
> raise TypeError("Expecting IP address, not network")
With the current API, you don't need to write it in such a quirky
way. Instead
if address.numhosts != 1:
raise TypeError("Expecting IP address, not network")
would do as well.
> Given its myriad quirks
Well, you deliberately make it appear more quirky than it actually is. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年06月02日 05:20:05 | loewis | set | recipients:
+ loewis, gvanrossum, gregory.p.smith, Rhamphoryncus, pitrou, giampaolo.rodola, benjamin.peterson, ezio.melotti, mattsmart, shields, pmoody, pnasrat, r.david.murray, oubiwann, claymation |
| 2009年06月02日 05:20:00 | loewis | link | issue3959 messages |
| 2009年06月02日 05:19:51 | loewis | create |
|