Skip to content

Commit f175e2d

Browse files
authored
support Enum
1 parent 828c061 commit f175e2d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

var_dump/_var_dump.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from __future__ import print_function
22
import sys
33

4+
try:
5+
from enum import Enum
6+
except expression as identifier:
7+
Enum = type(str)
8+
49
try:
510
from types import NoneType
611
except ImportError:
@@ -47,6 +52,10 @@ def display(o, space, num, key, typ, proret):
4752
st += '"%s"'
4853
l.append(o)
4954

55+
elif isinstance(o, Enum):
56+
st += "Enum(%s)"
57+
l.append(str(o))
58+
5059
elif isinstance(o, object):
5160
st += "object(%s) (%s)"
5261
l.append(o.__class__.__name__)
@@ -63,7 +72,10 @@ def display(o, space, num, key, typ, proret):
6372

6473
def dump(o, space, num, key, typ, proret):
6574
r = ''
66-
if type(o) in (str, int, float, long, bool, NoneType, unicode):
75+
if type(o) in (str, int, float, long, bool, NoneType, unicode, Enum):
76+
r += display(o, space, num, key, typ, proret)
77+
78+
elif isinstance(o, Enum):
6779
r += display(o, space, num, key, typ, proret)
6880

6981
elif isinstance(o, object):

0 commit comments

Comments
 (0)