From 3b370c7d9fc80a3e37c78472f4e91cadced92766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 3 Sep 2018 15:53:43 +0200 Subject: [PATCH] Update --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 117f697..9ffb82c 100644 --- a/README.md +++ b/README.md @@ -298,8 +298,8 @@ Datetime import datetime now = datetime.datetime.now() now.month # 3 -now.strftime('%Y%m%d') # 20180315 -now.strftime('%Y%m%d%H%M%S') # 20180315002834 +now.strftime('%Y%m%d') # '20180315' +now.strftime('%Y%m%d%H%M%S') # '20180315002834' ``` Arguments @@ -465,6 +465,14 @@ class (Enum): = , = auto() # Can be used for automatic indexing. ... + + @classmethod + def get_names(cls): + return [a.name for a in cls.__members__.values()] + + @classmethod + def get_values(cls): + return [a.value for a in cls.__members__.values()] ``` ```python @@ -477,6 +485,7 @@ class (Enum): ```python Cutlery = Enum('Cutlery', ['knife', 'fork', 'spoon']) +Cutlery = Enum('Cutlery', {'knife': 1, 'fork': 2, 'spoon': 3}) list() # == [, , ...] random.choice(list()) # == random ``` @@ -1053,6 +1062,8 @@ Basic Script Template # Usage: .py # +from collections import namedtuple +from enum import Enum import re import sys