Skip to content

Commit 9fd4101

Browse files
committed
Enhance documentation for antigravity and this modules
- Improve antigravity.py documentation: * Add comprehensive module docstring explaining xkcd references * Enhance geohash() function docstring with detailed parameters * Add usage examples and references to xkcd comics #353 and #426 * Include warnings about the humorous nature of the implementation - Improve this.py documentation: * Add module docstring explaining the Zen of Python and ROT13 encoding * Add inline comments explaining ROT13 dictionary construction * Improve variable descriptions and code clarity These improvements make the modules more accessible to developers and provide better context for understanding their purpose and functionality.
1 parent 9df477c commit 9fd4101

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-8
lines changed

Lib/antigravity.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
11

2+
"""
3+
Antigravity module - A humorous reference to xkcd comic #353.
4+
5+
This module contains a geohash function inspired by xkcd comic #426,
6+
which provides a humorous take on geolocation hashing.
7+
8+
Upon import, this module automatically opens xkcd comic #353 in your web browser.
9+
"""
10+
211
import webbrowser
312
import hashlib
413

14+
# Open the xkcd comic that inspired this module
515
webbrowser.open("https://xkcd.com/353/")
616

717
def geohash(latitude, longitude, datedow):
8-
'''Compute geohash() using the Munroe algorithm.
9-
10-
>>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
11-
37.857713 -122.544543
12-
13-
'''
18+
"""Compute geohash() using the Munroe algorithm.
19+
20+
This function implements a humorous geolocation hashing algorithm
21+
inspired by xkcd comic #426. It takes geographic coordinates and a date,
22+
then generates a "geohash" by combining the coordinates with values
23+
derived from an MD5 hash of the date.
24+
25+
Args:
26+
latitude (float): The latitude coordinate.
27+
longitude (float): The longitude coordinate.
28+
datedow (bytes): A date string in bytes format to use for hashing.
29+
30+
Returns:
31+
None: This function prints the result instead of returning it.
32+
33+
Example:
34+
>>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
35+
37.857713 -122.544543
36+
37+
Note:
38+
This is a humorous implementation and should not be used for
39+
actual geolocation purposes. For real geohashing, consider using
40+
a proper geohashing library.
41+
42+
References:
43+
- xkcd comic #426: https://xkcd.com/426/
44+
- xkcd comic #353: https://xkcd.com/353/
45+
"""
1446
# https://xkcd.com/426/
1547
h = hashlib.md5(datedow, usedforsecurity=False).hexdigest()
1648
p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]

Lib/this.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"""
2+
The Zen of Python, by Tim Peters
3+
4+
This module contains the famous "Zen of Python" poem by Tim Peters,
5+
encoded using ROT13 (rotate by 13 places) substitution cipher.
6+
7+
The module automatically decodes and prints the Zen of Python when imported.
8+
"""
9+
10+
# The Zen of Python encoded with ROT13
111
s = """Gur Mra bs Clguba, ol Gvz Crgref
212
313
Ornhgvshy vf orggre guna htyl.
@@ -20,9 +30,12 @@
2030
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.
2131
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!"""
2232

33+
# ROT13 translation dictionary
34+
# Maps each letter to the letter 13 positions later in the alphabet
2335
d = {}
24-
for c in (65, 97):
25-
for i in range(26):
36+
for c in (65, 97): # ASCII values for 'A' and 'a'
37+
for i in range(26): # 26 letters in the alphabet
2638
d[chr(i+c)] = chr((i+13) % 26 + c)
2739

40+
# Decode and print the Zen of Python
2841
print("".join([d.get(c, c) for c in s]))

0 commit comments

Comments
 (0)