Skip to content

Instantly share code, notes, and snippets.

@brianray
Created December 2, 2015 20:16
Show Gist options
  • Save brianray/75122e1b9cade047dc9d to your computer and use it in GitHub Desktop.
Save brianray/75122e1b9cade047dc9d to your computer and use it in GitHub Desktop.
fun way to prevent printing of passwords (maybe)
class PasswordStr(object):
"""by: [email protected]"""
scrubbed_msg = u"xxxxxSCRUBEDxxxxx"
def __init__(self, original):
self.original = original
def __str__(self):
return str(self.scrubbed_msg)
def __unicode__(self):
return self.scrubbed_msg
def __repr__(self):
return self.original
def __cmp__(self, other):
return cmp(self.original, self.original)
def __add__(self, other):
return self.original + other
my_pass = PasswordStr("secret")
print my_pass
x = my_pass
x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment