Skip to content

Commit 1e50506

Browse files
committed
Increase version, implement constant #12
1 parent 9705e86 commit 1e50506

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from distutils.core import setup
44

55
setup(name='underscore.py',
6-
version='0.1.5',
6+
version='0.1.6',
77
description='Port of underscore.js into python',
88
author='Serkan Yersen',
99
author_email='[email protected]',

src/underscore.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class underscore(object):
6161
""" Passed object
6262
"""
6363

64-
VERSION = "0.1.5"
64+
VERSION = "0.1.6"
6565

6666
chained = False
6767
""" If the object is in a chained state or not
@@ -1266,13 +1266,18 @@ def join(self, glue=" "):
12661266
j = glue.join([str(x) for x in self.obj])
12671267
return self._wrap(j)
12681268

1269+
def constant(self, *args):
1270+
""" High order of identity
1271+
"""
1272+
return self._wrap(lambda *args: self.obj)
1273+
12691274
def identity(self, *args):
12701275
""" Keep the identity function around for default iterators.
12711276
"""
12721277
return self._wrap(self.obj)
12731278

12741279
def property(self):
1275-
"""
1280+
""" For easy creation of iterators that pull specific properties from objects.
12761281
"""
12771282
return self._wrap(lambda obj, *args: obj[self.obj])
12781283

tests/test_utility.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def test_identity(self):
1717
moe = {"name": 'moe'}
1818
self.assertEqual(moe, _.identity(moe), "moe is the same as his identity")
1919

20+
def test_constant(self):
21+
moe = {"name" : 'moe'}
22+
self.assertEqual(_.constant(moe)(), moe, 'should create a function that returns moe')
23+
2024
def test_property(self):
2125
moe = {"name" : 'moe'}
2226
self.assertEqual(_.property('name')(moe), 'moe', 'should return the property with the given name')

0 commit comments

Comments
 (0)