/ Published in: Python
                    
                                        Simple ways to get enumerations in python.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 >>> Status = namedtuple('Status', 'open pending closed')._make(range(3)) >>> Status.open, Status.pending, Status.closed (0, 1, 2) >>> class Status: open, pending, closed = range(3) >>> Status.open, Status.pending, Status.closed (0, 1, 2)
Comments
                    Subscribe to comments
                
                