Skip to content

chatasweetie/creating-animals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overloading Operators in Python

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?

Screenshot

*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:

How to run locally

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')

About the Developer

Jessica Dene Earley
Short Bio
Linkedin
Blog-Overloading Operators in Python
Chatasweetie's Blog

About

overloading operators in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages