#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Inet_pton is not defined error


    Hi All,

    I'm new to Python but not new to programming. I'm running Python 3.3 under Windows 7

    In the python command line I enter:

    >>> from socket import *
    >>> add = repr(inet_pton(AF_INET, "192.168.0.3"))

    And I get the error "NameError: name 'inet_pton' is not defined"

    For some reason it looks like it doesn't fine inet_pton. How do I fix this? Is there another library that I need to load?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    The names you've imported into your module do not include inet_pton
    Code:
    >>> import socket, pprint
    >>> 
    >>> pprint.pprint(dir(socket))
    ...
     'herror',
     'htonl',
     'htons',
     'inet_aton',
     'inet_ntoa',
     'io',
     'ntohl',
     'ntohs',
    ...
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by b49P23TIvg
    The names you've imported into your module do not include inet_pton
    Code:
    >>> import socket, pprint
    >>> 
    >>> pprint.pprint(dir(socket))
    ...
     'herror',
     'htonl',
     'htons',
     'inet_aton',
     'inet_ntoa',
     'io',
     'ntohl',
     'ntohs',
    ...
    Any idea why? As I mentioned, I'm new to Python though I've been programming for 30 years. Is there a specific suggestion on how to fix it?
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    I've been a scientific programmer for thirty years. I know a good bit about python but little about sockets.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65
    socket.inet_pton(address_family, ip_string)
    might only be available on Unix systems.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo