aka. creating life!
Description
Creating animal objects and overloading the operator where different operators have different implementations depending on their arguments.
How it works
Create a animal object of your choosing - generic Animal, Cat or Dog. The object will have several characteristics that will influence what the operator will do.
Want more details?
- Check out the blog post: Overloading Operators in Python
*Check out the video: Overloading Operators in Python
*Making Cat Objects and using + and :
Making a Dog Object and using + and * with a Cat Object:
Making a generic Animal object and using +:
Making a rabbit with the Animal class and using * and +:
Objects keep track of who they are best friends with:
Create a virtual environment
> virtualenv env
> source env/bin/activate
Install the dependencies
> pip install -r requirements.txt
Run script using bpython in interactive mode
> bpython -i create.py
Create all the animals you'll like and have them become friends, mortal enemies, frenimeies and make new litters!
example:
> luna = Cat('luna')
Jessica Dene Earley
Short Bio
Linkedin
Blog-Overloading Operators in Python
Chatasweetie's Blog