"""Bunnies can be both adorable and dark."""
from lib import *
from typing import List, Optional
class Bunny(object):
"""an adorable object"""
name: Optional[str] = None
age: Optional[int] = None
hungry: bool = True
def __repr__(self):
if self.name is not None:
return self.name
else:
return 'sad bunny'
bunnies: List[Bunny] = list([Bunny()])
This project kicks off as a cute Python experiment about bunnies but swiftly descends into chaos, manifesting the perils of wildcard imports, overriding Python magic methods, and unexpected behavior with Python classes. Brace yourself for the mysterious journey of Dark Bunnies!
In the mystical world of Dark Bunnies, everything is not as it seems. At the heart of the chaos is the Dark class, a mysterious figure that can be quite unpredictable! It overrides Python's built-in methods to bewilder and amuse.
class Dark(object):
"""the darkest dark"""
ascii_b = None
from random import choice
from lib.cuteness import ascii_bunnies
def __str__(self):
if self.ascii_b is None:
self.ascii_b = self.choice(self.ascii_bunnies)
return self.ascii_b
def __len__(self) -> int:
return self.choice(range(1, 101))
In our world, even Python's help has a sarcastic streak. If you're asking for help, you better do it politely!
def help(*args: Any, **kwds: Any) -> None:
"""this is mean"""
if 'please' in kwds.keys():
_help(*args)
else:
if len(args) == 0:
print("I can't believe you don't understand python..")
else:
for arg in args:
try:
print(f"You don't know what an {arg.__name__} is...")
except AttributeError:
pass
Beware of the mischievous lists in Dark Bunnies' world! If a list has more than one item, it might spontaneously spawn a few bunnies.
class list(_list):
"""Built-in mutable sequence... or is it? If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified."""
from random import choice
from lib.cuteness import bunny_names
def __len__(self) -> int:
length = super(list, self).__len__()
if length >= 2:
t = type(self[0])
for _ in range(length // 2):
new = t()
new.name = self.choice(self.bunny_names)
self.append(new)
return super(list, self).__len__()
- Python Official Documentation: https://docs.python.org/3/
- Wildcard Imports: https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
- Recurse.com: https://www.recurse.com/
While our Dark Bunnies adventure may seem like all fun and games, it's a learning experience at its core. It teaches us the importance of understanding Python classes, wildcard imports, and overriding Python magic methods. Always be explicit about your imports, and be cautious when dealing with magic methods. Happy coding! πππ³οΈπ»π