Sunday 15 April 2012

Best Way to Structure Functions in Python -



Best Way to Structure Functions in Python -

i looking compare regular public ip address tor ip address connect net with. code below:-

def public_ip(): url = 'http://ifconfig.me/ip' request = urllib2.request(url) request.add_header('cache-control','max-age=0') response = urllib2.urlopen(request) print response.read() def connect_tor(): localhost = "127.0.0.1" port = 9150 socks.setdefaultproxy(socks.proxy_type_socks5, localhost, port) socket.socket = socks.socksocket url = 'http://ifconfig.me/ip' request = urllib2.request(url) request.add_header('cache-control','max-age=0') response = urllib2.urlopen(request) print response.read() if __name__ == "__main__": public_ip() connect_tor()

what i'm looking create 3rd function confirm value of ip address generated both functions confirm different. nonetheless, how can feed ip addresses first 2 functions 3rd function. here's thinking far i'm unsure of best option:-

1.) create 1 big function 3 functions 2.) create global variables , homecoming values global variables , utilize these in 3rd function 3.) phone call 'connect_tor' function within 'public_ip' function passing 'public_ip' 'connect_tor function' phone call 3rd function passing 2 ips parameters.

what best practice here or recommendations?

i add together homecoming value current functions public_ip() , connect_tor(). compare them:

print public_ip() != connect_tor()

this way can check anonymity while avoiding function altogether.

python python-2.7 tor

No comments:

Post a Comment