Reputation: 3075
Can someone explain this script?
device = {}
ua = request.META.get('HTTP_USER_AGENT', '').lower()
if ua.find("iphone") > 0:
device['iphone'] = "iphone" + re.search("iphone os (\d)", ua).groups(0)[0]
I know it gets the user agent and the first bit searches the string for iphone. but
why > 0? and what is the second like doing?
Upvotes: 0
Views: 316
Reputation: 17521
I am not a python guy but I am almost sure that .find()
returns position where the string "iphone" occurs.
So if it was found, it will be >= 0.
Upvotes: 1