Re: how to convert ip address to dot notation

Discussion in 'Python' started by =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Aug 4, 2003.

  1. Ruslan Spivak wrote:

    > Hello, python users!
    >
    > I have ip addresses in my mysql db in int value - 3232261127, for example.
    > How can i convert that to usual dot notation like 192.168.100.7?
    >
    > Thanks in advance.
    > Your help is very appreciated.


    If there's nothing in the standard library, something like

    def numIP2strIP(ip):
    l = [str((ip >> 8*n) % 256) for n in range(4)]
    l.reverse()
    return ".".join(l)

    should do.

    Or you could just use PostgreSQL where you you have a datatype for IP
    addresses :)

    -- Gerhard
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Aug 4, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruslan Spivak

    how to convert ip address to dot notation

    Ruslan Spivak, Aug 4, 2003, in forum: Python
    Replies:
    0
    Views:
    405
    Ruslan Spivak
    Aug 4, 2003
  2. Grey Squirrel

    Hungarian Notation Vs. Pascal Notation?

    Grey Squirrel, Mar 19, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    1,270
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Mar 21, 2007
  3. Tameem
    Replies:
    454
    Views:
    11,560
  4. Robert Mark Bram

    Dot notation V Bracket notation

    Robert Mark Bram, Jul 4, 2003, in forum: Javascript
    Replies:
    3
    Views:
    455
    Robert Mark Bram
    Jul 5, 2003
  5. Replies:
    6
    Views:
    224
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
Loading...

Share This Page