On 09/04/17 04:00, boB Stepp wrote: > understandable to me, but I am having difficulty imagining where I > might want to use these features. >
Steven has given the basics, here are a few more real world examples: Any kind of status value: (open,closed,opening, closing,locked) - control valve (on, off) - light (red,green,amber,red-amber) - uk traffic light small collections: days of week months in year (cleaning, reception, waiting, valet) - rota duties (hourly,daily,weekly,monthly,annual) - schedules Enums are very common in larger programs once you get used to the concept. It's a bit like dictionaries: many traditional programmers think of everything as arrays and can't initially think of when they would use a dictionary (arbitrary key rather than numeric index) But once you get started you find dictionaries are at least as useful as arrays.. And, surprise, surprise, there is a link. Very often enums form the set of valid keys to a dictionary... -- 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 _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
