##// END OF EJS Templates
Make isort usable without a key argument....
walter.doerwald -
Show More
@@ -1511,18 +1511,24 b' class isort(Pipe):'
1511 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1511 >>> ils | isort("_.isdir(), _.lower()", reverse=True)
1512 """
1512 """
1513
1513
1514 def __init__(self, key, globals=None, reverse=False):
1514 def __init__(self, key=None, globals=None, reverse=False):
1515 """
1515 """
1516 Create an ``isort`` object. ``key`` can be a callable or a string
1516 Create an ``isort`` object. ``key`` can be a callable or a string
1517 containing an expression. If ``reverse`` is true the sort order will
1517 containing an expression (or ``None`` in which case the items
1518 be reversed. For the meaning of ``globals`` see ``ifilter``.
1518 themselves will be sorted). If ``reverse`` is true the sort order
1519 will be reversed. For the meaning of ``globals`` see ``ifilter``.
1519 """
1520 """
1520 self.key = key
1521 self.key = key
1521 self.globals = globals
1522 self.globals = globals
1522 self.reverse = reverse
1523 self.reverse = reverse
1523
1524
1524 def __xiter__(self, mode):
1525 def __xiter__(self, mode):
1525 if callable(self.key):
1526 if self.key is None:
1527 items = sorted(
1528 xiter(self.input, mode),
1529 reverse=self.reverse
1530 )
1531 elif callable(self.key):
1526 items = sorted(
1532 items = sorted(
1527 xiter(self.input, mode),
1533 xiter(self.input, mode),
1528 key=self.key,
1534 key=self.key,
@@ -1,3 +1,8 b''
1 2006-07-13 Walter Doerwald <walter@livinglogic.de>
2
3 * IPython/Extensions/ipipe.py (isort): Make isort usable without
4 argument. This sorts the items themselves.
5
1 2006-07-12 Walter Doerwald <walter@livinglogic.de>
6 2006-07-12 Walter Doerwald <walter@livinglogic.de>
2
7
3 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
8 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
General Comments 0
You need to be logged in to leave comments. Login now