@@ -54,22 +54,41 @@ def next(obj, default=nothing):
54
54
55
55
PROJECT_CONFIG = ('setup.cfg' , 'tox.ini' , '.pep257' )
56
56
57
- humanize = lambda string : re (r'(.)([A-Z]+)' ).sub (r'\1 \2' , string ).lower ()
58
- is_magic = lambda name : name .startswith ('__' ) and name .endswith ('__' )
59
- is_ascii = lambda string : all (ord (char ) < 128 for char in string )
60
- is_blank = lambda string : not string .strip ()
61
- leading_space = lambda string : re ('\s*' ).match (string ).group ()
57
+
58
+ def humanize (string ):
59
+ return re (r'(.)([A-Z]+)' ).sub (r'\1 \2' , string ).lower ()
60
+
61
+
62
+ def is_magic (name ):
63
+ return name .startswith ('__' ) and name .endswith ('__' )
64
+
65
+
66
+ def is_ascii (string ):
67
+ return all (ord (char ) < 128 for char in string )
68
+
69
+
70
+ def is_blank (string ):
71
+ return not string .strip ()
72
+
73
+
74
+ def leading_space (string ):
75
+ return re ('\s*' ).match (string ).group ()
62
76
63
77
64
78
class Value (object ):
65
79
66
- __init__ = lambda self , * args : vars (self ).update (zip (self ._fields , args ))
67
- __hash__ = lambda self : hash (repr (self ))
68
- __eq__ = lambda self , other : other and vars (self ) == vars (other )
80
+ def __init__ (self , * args ):
81
+ vars (self ).update (zip (self ._fields , args ))
82
+
83
+ def __hash__ (self ):
84
+ return hash (repr (self ))
85
+
86
+ def __eq__ (self , other ):
87
+ return other and vars (self ) == vars (other )
69
88
70
89
def __repr__ (self ):
71
- format_arg = lambda arg : ' {}={!r}' .format (arg , getattr (self , arg ))
72
- kwargs = ', ' . join ( format_arg ( arg ) for arg in self ._fields )
90
+ kwargs = ', ' . join ( ' {}={!r}' .format (field , getattr (self , field ))
91
+ for field in self ._fields )
73
92
return '{}({})' .format (self .__class__ .__name__ , kwargs )
74
93
75
94
@@ -83,7 +102,9 @@ class Definition(Value):
83
102
all = property (lambda self : self .module .all )
84
103
_slice = property (lambda self : slice (self .start - 1 , self .end ))
85
104
source = property (lambda self : '' .join (self ._source [self ._slice ]))
86
- __iter__ = lambda self : chain ([self ], * self .children )
105
+
106
+ def __iter__ (self ):
107
+ return chain ([self ], * self .children )
87
108
88
109
@property
89
110
def _publicity (self ):
@@ -100,7 +121,9 @@ class Module(Definition):
100
121
_nest = staticmethod (lambda s : {'def' : Function , 'class' : Class }[s ])
101
122
module = property (lambda self : self )
102
123
all = property (lambda self : self ._all )
103
- __str__ = lambda self : 'at module level'
124
+
125
+ def __str__ (self ):
126
+ return 'at module level'
104
127
105
128
106
129
class Function (Definition ):
0 commit comments