-2

Update

If I do print(publicip.get()) then I get the correct ip addressed printed.

If I do myip = publicip.get() and then do print(myip), then the value None gets printed

Original Question

When I ran the site on localhost, the value of myip would be 127.0.0.1. But publicip.get() would give me my public IP address. Unfortunately if myip = "127.0.0.1": and if myip = 127.0.0.1: give me syntax errors. What is the correct way of checking the value in the variable myip.

     myip, is_routable = get_client_ip(request)
     if myip = "127.0.0.1":
        myip = publicip.get()

     print("myip")
     print(myip)
Ross Symonds
  • 690
  • 1
  • 8
  • 29

1 Answers1

2

= is an assignment operator, while equality can be checked with ==.

Heap Underflow
  • 377
  • 1
  • 12