Skip to content

Instantly share code, notes, and snippets.

@oyakata
Created December 28, 2011 02:09
Show Gist options
  • Save oyakata/1525832 to your computer and use it in GitHub Desktop.
Save oyakata/1525832 to your computer and use it in GitHub Desktop.
かけ算

result

♥♥

Press ENTER or type command to continue

# -*- coding:utf-8 -*-
BROKEN_HEART = "鬱"
class Person(object):
def __mul__(self, other):
if not isinstance(other, Person):
return BROKEN_HEART
return "♥♥"
def __rmul__(self, other):
if not isinstance(other, Person):
return BROKEN_HEART
return None
def main():
drillbits, pasberth = Person(), Person()
print(drillbits * pasberth)
feiz = Person()
print(feiz * None)
print(0 * feiz)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment