Optimize sub-optimal way of doing acrostics. (Is unnecessary optimization worse than...
authorKim Slawson <redacted>
Sun, 3 Mar 2013 05:41:03 +0000 (00:41 -0500)
committerKim Slawson <redacted>
Sun, 3 Mar 2013 05:41:03 +0000 (00:41 -0500)
xkcd-password.py

index 4427cb0645089412776aaf7bdd2fb450f93a29b8..c37ec940f0705f2a6f3303bb429c1da3f6f8037b 100755 (executable)
@@ -165,15 +165,15 @@ def generate_xkcdpassword(wordlist, n_words=4, interactive=False, acrostic=False
            return " ".join(rng().sample(wordlist, n_words))
         else:
             """
-            # slower but more elegant
+            # slower but more elegant. "pythonic"
             while 1:
                 words = " ".join(rng().sample(wordlist, n_words))
-                if acrostic.lower() == "".join(item[0].lower() for item in words.split()):
+                if acrostic.lower() == "".join(item[0] for item in words.split()).lower():
                     return words
                     break
             """
 
-            # faster but less elegant
+            # faster but less elegant. practical.
             words = ""
             for letter in acrostic:
                 while 1:
git clone https://git.99rst.org/PROJECT