diff --git a/Lib/antigravity.py b/Lib/antigravity.py index 6dc520733577af..eb9933dc875afb 100644 --- a/Lib/antigravity.py +++ b/Lib/antigravity.py @@ -1,16 +1,48 @@ +""" +Antigravity module - A humorous reference to xkcd comic #353. + +This module contains a geohash function inspired by xkcd comic #426, +which provides a humorous take on geolocation hashing. + +Upon import, this module automatically opens xkcd comic #353 in your web browser. +""" + import webbrowser import hashlib +# Open the xkcd comic that inspired this module webbrowser.open("https://xkcd.com/353/") def geohash(latitude, longitude, datedow): - '''Compute geohash() using the Munroe algorithm. - - >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') - 37.857713 -122.544543 - - ''' + """Compute geohash() using the Munroe algorithm. + + This function implements a humorous geolocation hashing algorithm + inspired by xkcd comic #426. It takes geographic coordinates and a date, + then generates a "geohash" by combining the coordinates with values + derived from an MD5 hash of the date. + + Args: + latitude (float): The latitude coordinate. + longitude (float): The longitude coordinate. + datedow (bytes): A date string in bytes format to use for hashing. + + Returns: + None: This function prints the result instead of returning it. + + Example: + >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68') + 37.857713 -122.544543 + + Note: + This is a humorous implementation and should not be used for + actual geolocation purposes. For real geohashing, consider using + a proper geohashing library. + + References: + - xkcd comic #426: https://xkcd.com/426/ + - xkcd comic #353: https://xkcd.com/353/ + """ # https://xkcd.com/426/ h = hashlib.md5(datedow, usedforsecurity=False).hexdigest() p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])] diff --git a/Lib/this.py b/Lib/this.py index e68dd3ff39b04f..880d6a67865b75 100644 --- a/Lib/this.py +++ b/Lib/this.py @@ -1,3 +1,13 @@ +""" +The Zen of Python, by Tim Peters + +This module contains the famous "Zen of Python" poem by Tim Peters, +encoded using ROT13 (rotate by 13 places) substitution cipher. + +The module automatically decodes and prints the Zen of Python when imported. +""" + +# The Zen of Python encoded with ROT13 s = """Gur Mra bs Clguba, ol Gvz Crgref Ornhgvshy vf orggre guna htyl. @@ -20,9 +30,12 @@ Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!""" +# ROT13 translation dictionary +# Maps each letter to the letter 13 positions later in the alphabet d = {} -for c in (65, 97): - for i in range(26): +for c in (65, 97): # ASCII values for 'A' and 'a' + for i in range(26): # 26 letters in the alphabet d[chr(i+c)] = chr((i+13) % 26 + c) +# Decode and print the Zen of Python print("".join([d.get(c, c) for c in s]))