Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'that?': 0.05; 'subject:missing': 0.07; 'occasionally': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'suggest': 0.14; '"python': 0.16; 'braces': 0.16; 'code),': 0.16; 'devs': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterates': 0.16; 'reasonably': 0.16; 'ternary': 0.16; 'variations': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'closely': 0.24; 'convenient': 0.24; 'exists': 0.24; 'of.': 0.24; "shouldn't": 0.24; 'fairly': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'source': 0.25; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'idea': 0.28; 'point': 0.28; 'function': 0.29; 'patch': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'went': 0.31; 'that.': 0.31; 'usually': 0.31; 'probably': 0.32; 'fri,': 0.33; 'proceed': 0.33; 'actual': 0.34; 'could': 0.34; "can't": 0.35; 'done.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'addresses,': 0.36; 'should': 0.36; 'clear': 0.37; 'connections': 0.38; 'e.g.': 0.38; 'pm,': 0.38; 'that,': 0.38; 'explain': 0.39; 'does': 0.39; 'though,': 0.39; 'sure': 0.39; 'mailing': 0.39; 'subject:? ': 0.60; 'simple': 0.61; "you'll": 0.62; "you've": 0.63; 'more': 0.64; 'different': 0.65; 'within': 0.65; 'internet': 0.71; 'million': 0.74; 'address,': 0.75; '2015': 0.84; 'friendly,': 0.84; 'subject:here': 0.84; 'to:none': 0.92; 'connection,': 0.95 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:cc :content-type; bh=eJtZgrt7K9dFf8mkdu24q16ClZ4mrVjtEpCAa4gLTkE=; b=mF3i+b1ttarVd0yKwUouIPaIdBfPIsmg/cUQy9CYfP44Jm6T4nsavRABOJ6I59OaHn wOi9biC3OYtMFsh3CfM0ISWhN2/9mOQrcYBX5eZYyaCmR8ItgHW8xhB5XdbFbIakLi0z 0HusYUiBVXt7p8LjWq7/DT/Tg5dM/PO+tKmR5Knj8Z3d+cx5gac5cvfJ/yAzPlpxae03 O1Moh14tjLQ0lUFrca6E/F8FwQdJo7HAS6ygvj9a7vGcZLvBPsw5PxOmV1PKMGy0Uagy cKVxADh0dRyK/hXMvQpfybBKZVMTrnM06d6slLSPZtAJreCGglKxY2K8GJ8ILAV5pT+4 am9w== MIME-Version: 1.0 X-Received: by 10.107.134.206 with SMTP id q75mr5405088ioi.27.1430481972217; Fri, 01 May 2015 05:06:12 -0700 (PDT) In-Reply-To: References: Date: Fri, 1 May 2015 22:06:12 +1000 Subject: Re: Am I missing something here? ipaddress vs socket From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430481980 news.xs4all.nl 2868 [2001:888:2000:d::a6]:50375 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89724 On Fri, May 1, 2015 at 8:41 PM, Ronald van Zantvoort wrote: > mystring is already an IP address, sorry for not mentioning that. > The point is that ternary if; I've been scouring around the internet and there's a million different variations on the same idea. > I'm completely flabberghasted it's not a simple property within the object though, e.g. ip.sock_family. > > Was this a deliberate decision by the Python devs or can I try an RFE for that? You could ask. At very worst, you'll find someone explain to you why it shouldn't be done. I suggest using the python-ideas mailing list; people there are usually reasonably friendly, though occasionally you find a caustic response to a dumb idea like "Python should use braces for indentation" :) >> But you may find it convenient to use a dedicated function for >> establishing a connection, which could look up an AAAA or A record for >> a name, then proceed through all addresses, attempting connections in >> turn. I'm fairly sure one exists in Python, but I can't right now >> remember the name. >> > Well you've already got socket.create_connection(), which (I think) does perform that lookup. Yeah, I went looking for it and came across that, but wasn't sure if that was it. Now I look more closely (ie: look at the actual source code), I see that it probably is the function I was thinking of. Might need a docs patch to make it clear that this iterates over getaddrinfo() and attempts them all in succession. ChrisA