[Tutor] What would be good use cases for the enum module?

Alan Gauld alan.gauld at yahoo.co.uk
Sun Apr 9 11:26:32 EDT 2017


On 09/04/17 13:58, Mats Wichmann wrote:

> All of these can of course be done without enums.  So the extra benefit
> of an enum is that the set is closed (immutable) and requires
> uniqueness: picking some other value will be an error, 

Indeed, good catch. The value of an enum over an integer is
that the values are limited to those prescribed by the enum,
any attempt to pass or create a different value will be an error.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list